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, code core.RecordRef, memory []byte) (*core.RecordRef, error)
- func (m *LedgerArtifactManager) ActivateObj(domain, request, class core.RecordRef, memory []byte) (*core.RecordRef, error)
- func (m *LedgerArtifactManager) AppendObjDelegate(domain, request, obj 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, types []core.RecordRef, ...) (*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) GetLatestObj(head core.RecordRef) (core.ObjectDescriptor, error)
- 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) GetDelegates() ([][]byte, error)
- func (d *ObjectDescriptor) HeadRef() *core.RecordRef
- func (d *ObjectDescriptor) Memory() ([]byte, error)
- func (d *ObjectDescriptor) StateRef() *core.RecordRef
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") )
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) 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(store storage.Store) (*LedgerArtifactManager, error)
NewArtifactManger creates new manager instance.
func (*LedgerArtifactManager) ActivateClass ¶
func (m *LedgerArtifactManager) ActivateClass( domain, request, code core.RecordRef, memory []byte, ) (*core.RecordRef, error)
ActivateClass creates activate class record in storage. Provided code reference will be used as a class code and memory as the default memory for class objects.
Activation reference will be this class'es identifier and referred as "class head".
func (*LedgerArtifactManager) ActivateObj ¶
func (m *LedgerArtifactManager) ActivateObj( domain, request, class 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) AppendObjDelegate ¶
func (m *LedgerArtifactManager) AppendObjDelegate( domain, request, obj core.RecordRef, memory []byte, ) (*core.RecordRef, error)
AppendObjDelegate creates append object record in storage. Provided reference should be a reference to the head of the object. Provided memory well be used as append delegate memory.
Object's delegates will be provided by GetLatestObj. Any object update will nullify all the object's append delegates. VM is responsible for collecting all appends and adding them to the new memory manually if its required.
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, types []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) GetLatestObj ¶
func (m *LedgerArtifactManager) GetLatestObj(head core.RecordRef) (core.ObjectDescriptor, error)
GetLatestObj returns descriptors for latest known state of the object/class known to the storage. The caller should provide latest known states of the object/class known to it. If the object or the class is deactivated, an error should be returned.
Returned descriptors will provide methods for fetching migrations and appends relative to the provided states.
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.
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.
This will nullify all the object's append delegates. VM is responsible for collecting all appends and adding them to the new memory manually if its required.
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) GetDelegates ¶
func (d *ObjectDescriptor) GetDelegates() ([][]byte, error)
GetDelegates fetches unamended delegates from storage.
VM is responsible for collecting all delegates and adding them to the object memory manually if its required. TODO: not used for now
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.