Documentation ¶
Overview ¶
Package record contains code and types for storage records manipulation.
Index ¶
- Constants
- func Encode(rec Record) ([]byte, error)
- func EncodePulseNum(pulse PulseNum) []byte
- func EncodeRaw(raw *Raw) ([]byte, error)
- func ID2Bytes(id ID) []byte
- func MustEncode(rec Record) []byte
- func MustEncodeRaw(raw *Raw) []byte
- func SHA3Hash224(rec Record) []byte
- type ActivationRecord
- type AmendRecord
- type CallRequest
- type ClassActivateRecord
- type ClassAmendRecord
- type CodeRecord
- type DeactivationRecord
- type EnforcedObjectAmendRecord
- type ID
- type LockUnlockRequest
- type LockUnlockResult
- type Memory
- type ObjectActivateRecord
- type ObjectAmendRecord
- type ObjectAppendRecord
- type ProjectionType
- type PulseNum
- type Raw
- type ReadObject
- type ReadObjectComposite
- type ReadObjectResult
- type ReadRecordRequest
- type ReadRecordResult
- type ReadRequest
- type ReasonCode
- type Record
- type Reference
- type RejectionResult
- type RequestRecord
- type ResultRecord
- type SpecialResult
- type StatefulCallResult
- type StatefulExceptionResult
- type StatefulResult
- type StatelessCallResult
- type StatelessExceptionResult
- type StatelessResult
- type StorageRecord
- type TypeID
- type TypeRecord
- type WipeOutRecord
Constants ¶
const ( // HashSize is a record hash size. We use 224-bit SHA-3 hash (28 bytes). HashSize = 28 // PulseNumSize - 4 bytes is a PulseNum size (uint32) PulseNumSize = 4 // IDSize is the size in bytes of ID binary representation. IDSize = PulseNumSize + HashSize // RefIDSize is the size in bytes of Reference binary representation. RefIDSize = IDSize * 2 )
Variables ¶
This section is empty.
Functions ¶
func EncodePulseNum ¶ added in v0.0.3
EncodePulseNum serializes pulse number.
func MustEncode ¶ added in v0.0.2
MustEncode wraps Encode, panics on encoding errors.
func MustEncodeRaw ¶ added in v0.0.2
MustEncodeRaw wraps EncodeRaw, panics on encode errors.
func SHA3Hash224 ¶ added in v0.0.2
SHA3Hash224 hashes Record by it's CBOR representation and type identifier.
Types ¶
type ActivationRecord ¶
type ActivationRecord struct { StatefulResult GoverningDomain Reference }
ActivationRecord is an activation record.
type AmendRecord ¶
type AmendRecord struct { StatefulResult HeadRecord Reference AmendedRecord Reference }
AmendRecord is produced when we modify another record in ledger.
type CallRequest ¶
type CallRequest struct { RequestRecord CallInterface Reference CallMethodSignature uint32 ParamMemory Memory }
CallRequest is a contract execution request. Implements io.ReadWriter interface.
func (*CallRequest) CallMethod ¶
func (r *CallRequest) CallMethod() uint32
CallMethod is a contract method number to call.
type ClassActivateRecord ¶
type ClassActivateRecord struct { ActivationRecord CodeRecord Reference DefaultMemory Memory }
ClassActivateRecord is produced when we "activate" new contract class.
type ClassAmendRecord ¶
type ClassAmendRecord struct { AmendRecord NewCode Reference // CodeRecord Migrations []Reference // CodeRecord }
ClassAmendRecord is an amendment record for classes.
type CodeRecord ¶
type CodeRecord struct { StorageRecord TargetedCode map[core.MachineType][]byte SourceCode string Types []Reference }
CodeRecord is a code storage record.
func (*CodeRecord) GetCode ¶ added in v0.0.2
func (r *CodeRecord) GetCode(archPref []core.MachineType) ([]byte, error)
GetCode returns class code according to provided architecture preferences. If preferences are not provided or the record does not contain code for any of provided architectures an error will be returned.
type DeactivationRecord ¶
type DeactivationRecord struct {
AmendRecord
}
DeactivationRecord marks targeted object as disabled.
type EnforcedObjectAmendRecord ¶
type EnforcedObjectAmendRecord struct {
ObjectAmendRecord
}
EnforcedObjectAmendRecord is an enforced amendment record for objects.
type ID ¶ added in v0.0.2
ID is a composite identifier for records.
Hash is a bytes slice here to avoid copy of Hash array.
type LockUnlockRequest ¶
type LockUnlockRequest struct { RequestRecord Transaction Reference ExpectedLockDuration time.Duration }
LockUnlockRequest is a request to temporary lock (or unlock) another record.
type LockUnlockResult ¶
type LockUnlockResult struct {
SpecialResult
}
LockUnlockResult is a result of lock/unlock attempts.
type ObjectActivateRecord ¶
type ObjectActivateRecord struct { ActivationRecord ClassActivateRecord Reference Memory Memory }
ObjectActivateRecord is produced when we instantiate new object from an available class.
type ObjectAmendRecord ¶
type ObjectAmendRecord struct { AmendRecord NewMemory Memory }
ObjectAmendRecord is an amendment record for objects.
type ObjectAppendRecord ¶
type ObjectAppendRecord struct { AmendRecord AppendMemory Memory }
ObjectAppendRecord is an "append state" record for objects. It does not contain full actual state.
type ProjectionType ¶
type ProjectionType uint32
ProjectionType is a "view filter" for record. E.g. we can read whole object or just it's hash.
type PulseNum ¶ added in v0.0.2
type PulseNum uint32
PulseNum is a sequential number of Pulse. Upper 2 bits are reserved for use in references (scope), must be zero otherwise. Valid Absolute PulseNum must be >65536. If PulseNum <65536 it is a relative PulseNum
const SpecialPulseNumber PulseNum = 65536
SpecialPulseNumber - special value of PulseNum, it means a Drop-relative Pulse Number. It is only allowed for Storage.
func DecodePulseNum ¶ added in v0.0.3
DecodePulseNum deserializes pulse number.
func (PulseNum) Bytes ¶ added in v0.0.2
Bytes evaluates bytes representation of PulseNum and Record pair.
type Raw ¶ added in v0.0.2
Raw struct contains raw serialized record. We need raw blob to not have dependency on record structure changes in future, and have ability of consistent hash checking on old records.
func DecodeToRaw ¶ added in v0.0.2
DecodeToRaw decodes bytes to Raw struct from CBOR.
func EncodeToRaw ¶ added in v0.0.2
EncodeToRaw converts record to Raw record.
type ReadObject ¶
type ReadObject struct { ReadRequest ProjectionType ProjectionType }
ReadObject is a request type
type ReadObjectComposite ¶
type ReadObjectComposite struct { ReadObject CompositeType Reference }
ReadObjectComposite is a request to read object including it's "injected" fields.
type ReadObjectResult ¶
type ReadObjectResult struct { StatelessResult State int32 MemoryProjection Memory }
ReadObjectResult contains necessary object's memory.
type ReadRecordRequest ¶
type ReadRecordRequest struct { ReadRequest ExpectedRecordType TypeID }
ReadRecordRequest is a request type to read another record.
type ReadRecordResult ¶
type ReadRecordResult struct { StatelessResult RecordBody []byte }
ReadRecordResult just contains necessary record from storage.
type ReadRequest ¶
type ReadRequest struct {
RequestRecord
}
ReadRequest is a request type to read data.
type Record ¶
type Record interface {
Domain() *Reference
}
Record is base interface for all records.
type Reference ¶
Reference allows to address any record across the whole network.
func Core2Reference ¶ added in v0.0.5
Core2Reference converts commonly used reference to Ledger-specific.
func (*Reference) CoreRef ¶ added in v0.0.5
CoreRef generates Reference byte representation (key without prefix).
func (Reference) IsNotEqual ¶ added in v0.0.2
IsNotEqual checks non equality of References.
type RejectionResult ¶
type RejectionResult struct {
SpecialResult
}
RejectionResult is a result type for failed attempts.
type RequestRecord ¶
RequestRecord is common type for all requests.
func (*RequestRecord) Domain ¶ added in v0.0.2
func (rec *RequestRecord) Domain() *Reference
Domain implements Record interface
type ResultRecord ¶
ResultRecord is a common type for all results.
func (*ResultRecord) Domain ¶ added in v0.0.2
func (rec *ResultRecord) Domain() *Reference
Domain implements Record interface
type SpecialResult ¶
type SpecialResult struct { ResultRecord ReasonCode ReasonCode }
SpecialResult is a result type for special situations.
type StatefulCallResult ¶
type StatefulCallResult struct { ObjectAmendRecord ResultMemory Memory }
StatefulCallResult is a contract call result that produces new state.
type StatefulExceptionResult ¶
type StatefulExceptionResult struct { StatefulCallResult ExceptionType Reference }
StatefulExceptionResult is an exception result that needs to be stored.
type StatefulResult ¶
type StatefulResult struct {
ResultRecord
}
StatefulResult is a result type which contents need to be persistently stored.
type StatelessCallResult ¶
type StatelessCallResult struct { StatelessResult ResultMemory Memory }
StatelessCallResult is a contract call result that didn't produce new state.
type StatelessExceptionResult ¶
type StatelessExceptionResult struct { StatelessCallResult ExceptionType Reference }
StatelessExceptionResult is an exception result that does not need to be stored.
type StatelessResult ¶
type StatelessResult struct {
ResultRecord
}
StatelessResult is a result type that does not need to be stored.
type StorageRecord ¶
type StorageRecord struct {
StatefulResult
}
StorageRecord is produced when we store something in ledger. Code, data etc.
type TypeRecord ¶ added in v0.0.5
type TypeRecord struct { StorageRecord TypeDeclaration []byte }
TypeRecord is a code interface declaration.
type WipeOutRecord ¶
type WipeOutRecord struct { ResultRecord Replacement Reference WipedHash [HashSize]byte }
WipeOutRecord is a special record that takes place of another record when we need to completely wipe out some information from storage (think GDPR).