Documentation ¶
Overview ¶
Package artifactmanager provides high-level storage API for logic runner module.
Index ¶
- Variables
- type ClassDescriptor
- type CodeDescriptor
- type LedgerArtifactManager
- func (m *LedgerArtifactManager) ActivateClass(domain, request core.RecordRef) (*core.RecordRef, error)
- func (m *LedgerArtifactManager) ActivateObj(domain, request, class, parent core.RecordRef, memory []byte) (*core.RecordRef, error)
- func (m *LedgerArtifactManager) ActivateObjDelegate(domain, request, class, parent core.RecordRef, memory []byte) (*core.RecordRef, error)
- func (m *LedgerArtifactManager) DeactivateClass(domain, request, class core.RecordRef) (*core.RecordRef, error)
- func (m *LedgerArtifactManager) DeactivateObj(domain, request, obj core.RecordRef) (*core.RecordRef, error)
- func (m *LedgerArtifactManager) DeclareType(domain, request core.RecordRef, typeDec []byte) (*core.RecordRef, error)
- func (m *LedgerArtifactManager) DeployCode(domain, request core.RecordRef, codeMap map[core.MachineType][]byte) (*core.RecordRef, error)
- func (m *LedgerArtifactManager) GetCode(code core.RecordRef) (core.CodeDescriptor, error)
- func (m *LedgerArtifactManager) GetExactObj(classState, objectState core.RecordRef) ([]byte, []byte, error)
- func (m *LedgerArtifactManager) GetLatestClass(head core.RecordRef) (core.ClassDescriptor, error)
- func (m *LedgerArtifactManager) GetLatestObj(head core.RecordRef) (core.ObjectDescriptor, error)
- func (m *LedgerArtifactManager) GetObjChildren(head core.RecordRef) (core.RefIterator, error)
- func (m *LedgerArtifactManager) GetObjDelegate(head, asClass core.RecordRef) (*core.RecordRef, error)
- func (m *LedgerArtifactManager) RootRef() *core.RecordRef
- func (m *LedgerArtifactManager) SetArchPref(pref []core.MachineType)
- func (m *LedgerArtifactManager) UpdateClass(domain, request, class, code core.RecordRef, migrations []core.RecordRef) (*core.RecordRef, error)
- func (m *LedgerArtifactManager) UpdateObj(domain, request, obj core.RecordRef, memory []byte) (*core.RecordRef, error)
- type ObjectDescriptor
- func (d *ObjectDescriptor) ClassDescriptor() (core.ClassDescriptor, error)
- func (d *ObjectDescriptor) CodeDescriptor() (core.CodeDescriptor, error)
- func (d *ObjectDescriptor) HeadRef() *core.RecordRef
- func (d *ObjectDescriptor) Memory() ([]byte, error)
- func (d *ObjectDescriptor) StateRef() *core.RecordRef
- type RefIterator
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidRef = errors.New("invalid reference") ErrClassDeactivated = errors.New("class is deactivated") ErrObjectDeactivated = errors.New("object is deactivated") ErrInconsistentIndex = errors.New("inconsistent index") ErrWrongObject = errors.New("provided object is not and instance of provided class") ErrNotFound = errors.New("object not found") )
Custom errors possibly useful to check by artifact manager callers.
Functions ¶
This section is empty.
Types ¶
type ClassDescriptor ¶
type ClassDescriptor struct {
// contains filtered or unexported fields
}
ClassDescriptor represents meta info required to fetch all class data.
func (*ClassDescriptor) CodeDescriptor ¶ added in v0.0.5
func (d *ClassDescriptor) CodeDescriptor() (core.CodeDescriptor, error)
CodeDescriptor returns descriptor for fetching object's code data.
func (*ClassDescriptor) GetMigrations ¶
func (d *ClassDescriptor) GetMigrations() ([][]byte, error)
GetMigrations fetches all migrations from provided to artifact manager state to the last state known to storage. VM is responsible for applying these migrations and updating objects. TODO: not used for now
func (*ClassDescriptor) HeadRef ¶ added in v0.0.5
func (d *ClassDescriptor) HeadRef() *core.RecordRef
HeadRef returns head reference to represented class record.
func (*ClassDescriptor) StateRef ¶
func (d *ClassDescriptor) StateRef() *core.RecordRef
StateRef returns reference to represented class state record.
type CodeDescriptor ¶ added in v0.0.5
type CodeDescriptor struct {
// contains filtered or unexported fields
}
CodeDescriptor represents meta info required to fetch all code data.
func (*CodeDescriptor) Code ¶ added in v0.0.5
func (d *CodeDescriptor) Code() ([]byte, error)
Code fetches code from storage. Code will be fetched according to architecture preferences set via SetArchPref in artifact manager. If preferences are not provided, an error will be returned.
func (*CodeDescriptor) MachineType ¶ added in v0.0.6
func (d *CodeDescriptor) MachineType() (core.MachineType, error)
MachineType fetches code from storage and returns first available machine type according to architecture preferences.
Code for returned machine type will be fetched by Code method.
func (*CodeDescriptor) Ref ¶ added in v0.0.5
func (d *CodeDescriptor) Ref() *core.RecordRef
Ref returns reference to represented code record.
type LedgerArtifactManager ¶
type LedgerArtifactManager struct {
// contains filtered or unexported fields
}
LedgerArtifactManager provides concrete API to storage for processing module
func NewArtifactManger ¶ added in v0.0.5
func NewArtifactManger(db *storage.DB) (*LedgerArtifactManager, error)
NewArtifactManger creates new manager instance.
func (*LedgerArtifactManager) ActivateClass ¶
func (m *LedgerArtifactManager) ActivateClass( domain, request core.RecordRef, ) (*core.RecordRef, error)
ActivateClass creates activate class record in storage. Provided code reference will be used as a class code.
Activation reference will be this class'es identifier and referred as "class head".
func (*LedgerArtifactManager) ActivateObj ¶
func (m *LedgerArtifactManager) ActivateObj( domain, request, class, parent core.RecordRef, memory []byte, ) (*core.RecordRef, error)
ActivateObj creates activate object record in storage. Provided class reference will be used as objects class memory as memory of crated object. If memory is not provided, the class default memory will be used.
Activation reference will be this object's identifier and referred as "object head".
func (*LedgerArtifactManager) ActivateObjDelegate ¶ added in v0.0.6
func (m *LedgerArtifactManager) ActivateObjDelegate( domain, request, class, parent core.RecordRef, memory []byte, ) (*core.RecordRef, error)
ActivateObjDelegate is similar to ActivateObj but it created object will be parent's delegate of provided class.
func (*LedgerArtifactManager) DeactivateClass ¶
func (m *LedgerArtifactManager) DeactivateClass( domain, request, class core.RecordRef, ) (*core.RecordRef, error)
DeactivateClass creates deactivate record in storage. Provided reference should be a reference to the head of the class. If class is already deactivated, an error should be returned.
Deactivated class cannot be changed or instantiate objects.
func (*LedgerArtifactManager) DeactivateObj ¶
func (m *LedgerArtifactManager) DeactivateObj( domain, request, obj core.RecordRef, ) (*core.RecordRef, error)
DeactivateObj creates deactivate object record in storage. Provided reference should be a reference to the head of the object. If object is already deactivated, an error should be returned.
Deactivated object cannot be changed.
func (*LedgerArtifactManager) DeclareType ¶ added in v0.0.5
func (m *LedgerArtifactManager) DeclareType( domain, request core.RecordRef, typeDec []byte, ) (*core.RecordRef, error)
DeclareType creates new type record in storage.
Type is a contract interface. It contains one method signature.
func (*LedgerArtifactManager) DeployCode ¶
func (m *LedgerArtifactManager) DeployCode( domain, request core.RecordRef, codeMap map[core.MachineType][]byte, ) (*core.RecordRef, error)
DeployCode creates new code record in storage.
Code records are used to activate class or as migration code for an object.
func (*LedgerArtifactManager) GetCode ¶ added in v0.0.5
func (m *LedgerArtifactManager) GetCode(code core.RecordRef) (core.CodeDescriptor, error)
GetCode returns code from code record by provided reference.
This method is used by VM to fetch code for execution.
func (*LedgerArtifactManager) GetExactObj ¶
func (m *LedgerArtifactManager) GetExactObj( classState, objectState core.RecordRef, ) ([]byte, []byte, error)
GetExactObj returns code and memory of provided object/class state. Deactivation records should be ignored (e.g. object considered to be active).
This method is used by validator to fetch the exact state of the object that was used by the executor. TODO: not used for now
func (*LedgerArtifactManager) GetLatestClass ¶ added in v0.0.6
func (m *LedgerArtifactManager) GetLatestClass(head core.RecordRef) (core.ClassDescriptor, error)
GetLatestClass returns descriptor for latest state of the class known to storage. If the class is deactivated, an error should be returned.
Returned descriptor will provide methods for fetching all related data.
func (*LedgerArtifactManager) GetLatestObj ¶
func (m *LedgerArtifactManager) GetLatestObj(head core.RecordRef) (core.ObjectDescriptor, error)
GetLatestObj returns descriptor for latest state of the object known to storage. If the object or the class is deactivated, an error should be returned.
Returned descriptor will provide methods for fetching all related data.
func (*LedgerArtifactManager) GetObjChildren ¶ added in v0.0.6
func (m *LedgerArtifactManager) GetObjChildren(head core.RecordRef) (core.RefIterator, error)
GetObjChildren returns provided object's children references.
func (*LedgerArtifactManager) GetObjDelegate ¶ added in v0.0.6
func (m *LedgerArtifactManager) GetObjDelegate(head, asClass core.RecordRef) (*core.RecordRef, error)
GetObjDelegate returns provided object's delegate reference for provided class.
Object delegate should be previously created for this object. If object delegate does not exist, an error will be returned.
func (*LedgerArtifactManager) RootRef ¶ added in v0.0.6
func (m *LedgerArtifactManager) RootRef() *core.RecordRef
RootRef returns the root record reference.
Root record is the parent for all top-level records.
func (*LedgerArtifactManager) SetArchPref ¶
func (m *LedgerArtifactManager) SetArchPref(pref []core.MachineType)
SetArchPref Stores a list of preferred VM architectures memory.
When returning classes storage will return compiled code according to this preferences. VM is responsible for calling this method before fetching object in a new process. If preference is not provided, object getters will return an error.
func (*LedgerArtifactManager) UpdateClass ¶
func (m *LedgerArtifactManager) UpdateClass( domain, request, class, code core.RecordRef, migrations []core.RecordRef, ) (*core.RecordRef, error)
UpdateClass creates amend class record in storage. Provided reference should be a reference to the head of the class. Migrations are references to code records.
Returned reference will be the latest class state (exact) reference. Migration code will be executed by VM to migrate objects memory in the order they appear in provided slice.
func (*LedgerArtifactManager) UpdateObj ¶
func (m *LedgerArtifactManager) UpdateObj( domain, request, obj core.RecordRef, memory []byte, ) (*core.RecordRef, error)
UpdateObj creates amend object record in storage. Provided reference should be a reference to the head of the object. Provided memory well be the new object memory.
Returned reference will be the latest object state (exact) reference.
type ObjectDescriptor ¶
type ObjectDescriptor struct {
// contains filtered or unexported fields
}
ObjectDescriptor represents meta info required to fetch all object data.
func (*ObjectDescriptor) ClassDescriptor ¶ added in v0.0.5
func (d *ObjectDescriptor) ClassDescriptor() (core.ClassDescriptor, error)
ClassDescriptor returns descriptor for fetching object's class data.
func (*ObjectDescriptor) CodeDescriptor ¶ added in v0.0.5
func (d *ObjectDescriptor) CodeDescriptor() (core.CodeDescriptor, error)
CodeDescriptor returns descriptor for fetching object's code data.
func (*ObjectDescriptor) HeadRef ¶ added in v0.0.5
func (d *ObjectDescriptor) HeadRef() *core.RecordRef
HeadRef returns reference to represented object record.
func (*ObjectDescriptor) Memory ¶ added in v0.0.5
func (d *ObjectDescriptor) Memory() ([]byte, error)
Memory fetches latest memory of the object known to storage.
func (*ObjectDescriptor) StateRef ¶
func (d *ObjectDescriptor) StateRef() *core.RecordRef
StateRef returns reference to object state record.
type RefIterator ¶ added in v0.0.6
type RefIterator struct {
// contains filtered or unexported fields
}
func (*RefIterator) HasNext ¶ added in v0.0.6
func (i *RefIterator) HasNext() bool