record

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package record contains code and types for storage records manipulation.

Index

Constants

View Source
const RelativePulseNumber core.PulseNumber = 65536

RelativePulseNumber - special value of PulseNum, it means a Drop-relative Pulse Number. It is only allowed for Storage.

Variables

This section is empty.

Functions

func Encode added in v0.0.2

func Encode(rec Record) ([]byte, error)

Encode serializes record to CBOR.

func EncodeRaw added in v0.0.2

func EncodeRaw(raw *Raw) ([]byte, error)

EncodeRaw encodes Raw to CBOR.

func ID2Bytes added in v0.0.2

func ID2Bytes(id ID) []byte

ID2Bytes converts ID struct to it's byte representation.

func MustEncode added in v0.0.2

func MustEncode(rec Record) []byte

MustEncode wraps Encode, panics on encoding errors.

func MustEncodeRaw added in v0.0.2

func MustEncodeRaw(raw *Raw) []byte

MustEncodeRaw wraps EncodeRaw, panics on encode errors.

func SHA3Hash224 added in v0.0.2

func SHA3Hash224(rec Record) []byte

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.

func (*CallRequest) Read

func (r *CallRequest) Read(p []byte) (n int, err error)

Read allows to read Request's paramMemory.

func (*CallRequest) Write

func (r *CallRequest) Write(p []byte) (n int, err error)

Write allows to write to Request's paramMemory.

type ClassActivateRecord

type ClassActivateRecord struct {
	ActivationRecord

	DefaultMemory Memory
}

ClassActivateRecord is produced when we "activate" new contract class.

func (*ClassActivateRecord) GetCode added in v0.3.0

func (r *ClassActivateRecord) GetCode() *Reference

func (*ClassActivateRecord) IsAmend added in v0.3.0

func (r *ClassActivateRecord) IsAmend() bool

func (*ClassActivateRecord) IsDeactivation added in v0.3.0

func (r *ClassActivateRecord) IsDeactivation() bool

type ClassAmendRecord

type ClassAmendRecord struct {
	AmendRecord

	NewCode    Reference   // CodeRecord
	Migrations []Reference // CodeRecord
}

ClassAmendRecord is an amendment record for classes.

func (*ClassAmendRecord) GetCode added in v0.3.0

func (r *ClassAmendRecord) GetCode() *Reference

func (*ClassAmendRecord) IsAmend added in v0.3.0

func (r *ClassAmendRecord) IsAmend() bool

func (*ClassAmendRecord) IsDeactivation added in v0.3.0

func (r *ClassAmendRecord) IsDeactivation() bool

type ClassState added in v0.3.0

type ClassState interface {
	IsDeactivation() bool
	IsAmend() bool
	GetCode() *Reference
}

type CodeRecord

type CodeRecord struct {
	StorageRecord

	TargetedCode map[core.MachineType][]byte
	SourceCode   string
}

CodeRecord is a code storage record.

func (*CodeRecord) GetCode added in v0.0.2

func (r *CodeRecord) GetCode(archPref []core.MachineType) ([]byte, core.MachineType, 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.

func (*DeactivationRecord) GetCode added in v0.3.0

func (*DeactivationRecord) GetCode() *Reference

func (*DeactivationRecord) GetMemory added in v0.3.0

func (*DeactivationRecord) GetMemory() []byte

func (*DeactivationRecord) IsAmend added in v0.3.0

func (*DeactivationRecord) IsAmend() bool

func (*DeactivationRecord) IsDeactivation added in v0.3.0

func (*DeactivationRecord) IsDeactivation() bool

type EnforcedObjectAmendRecord

type EnforcedObjectAmendRecord struct {
	ObjectAmendRecord
}

EnforcedObjectAmendRecord is an enforced amendment record for objects.

type ID added in v0.0.2

type ID struct {
	Pulse core.PulseNumber
	Hash  []byte
}

ID is a composite identifier for records.

Hash is a bytes slice here to avoid copy of Hash array.

func Bytes2ID added in v0.0.2

func Bytes2ID(b []byte) ID

Bytes2ID converts ID from byte representation to struct.

func (ID) IsEqual added in v0.0.2

func (id ID) IsEqual(id2 ID) bool

IsEqual checks equality of IDs.

func (ID) WriteHash added in v0.0.2

func (id ID) WriteHash(w io.Writer)

WriteHash implements hash.Writer interface.

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 Memory

type Memory []byte

Memory is actual contracts' state, variables etc.

type ObjectActivateRecord

type ObjectActivateRecord struct {
	ActivationRecord

	ClassActivateRecord Reference
	Memory              Memory
	Parent              Reference
	Delegate            bool
}

ObjectActivateRecord is produced when we instantiate new object from an available class.

func (*ObjectActivateRecord) GetMemory added in v0.3.0

func (r *ObjectActivateRecord) GetMemory() []byte

func (*ObjectActivateRecord) IsAmend added in v0.3.0

func (r *ObjectActivateRecord) IsAmend() bool

func (*ObjectActivateRecord) IsDeactivation added in v0.3.0

func (r *ObjectActivateRecord) IsDeactivation() bool

type ObjectAmendRecord

type ObjectAmendRecord struct {
	AmendRecord

	NewMemory Memory
}

ObjectAmendRecord is an amendment record for objects.

func (*ObjectAmendRecord) GetMemory added in v0.3.0

func (r *ObjectAmendRecord) GetMemory() []byte

func (*ObjectAmendRecord) IsAmend added in v0.3.0

func (r *ObjectAmendRecord) IsAmend() bool

func (*ObjectAmendRecord) IsDeactivation added in v0.3.0

func (r *ObjectAmendRecord) IsDeactivation() bool

type ObjectAppendRecord

type ObjectAppendRecord struct {
	AmendRecord

	AppendMemory Memory
}

ObjectAppendRecord is an "append state" record for objects. It does not contain full actual state.

type ObjectState added in v0.3.0

type ObjectState interface {
	IsDeactivation() bool
	IsAmend() bool
	GetMemory() []byte
}

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 Raw added in v0.0.2

type Raw struct {
	Type TypeID
	Data []byte
}

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

func DecodeToRaw(b []byte) (*Raw, error)

DecodeToRaw decodes bytes to Raw struct from CBOR.

func EncodeToRaw added in v0.0.2

func EncodeToRaw(rec Record) (*Raw, error)

EncodeToRaw converts record to Raw record.

func (*Raw) Hash added in v0.0.2

func (raw *Raw) Hash() []byte

Hash generates hash for Raw record.

func (*Raw) ToRecord added in v0.0.2

func (raw *Raw) ToRecord() Record

ToRecord decodes Raw to 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 ReasonCode

type ReasonCode uint32

ReasonCode is an error reason code.

type Record

type Record interface {
	Domain() *Reference
}

Record is base interface for all records.

type Reference

type Reference struct {
	Domain ID
	Record ID
}

Reference allows to address any record across the whole network.

func Core2Reference added in v0.0.5

func Core2Reference(cRef core.RecordRef) Reference

Core2Reference converts commonly used reference to Ledger-specific.

func (*Reference) CoreRef added in v0.0.5

func (ref *Reference) CoreRef() *core.RecordRef

CoreRef generates Reference byte representation (key without prefix).

func (Reference) IsEqual added in v0.0.2

func (ref Reference) IsEqual(ref2 Reference) bool

IsEqual checks equality of References.

func (Reference) IsNotEqual added in v0.0.2

func (ref Reference) IsNotEqual(ref2 Reference) bool

IsNotEqual checks non equality of References.

type RejectionResult

type RejectionResult struct {
	SpecialResult
}

RejectionResult is a result type for failed attempts.

type RequestRecord

type RequestRecord struct {
	Requester Reference
	Target    Reference
}

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

type ResultRecord struct {
	DomainRecord  Reference
	RequestRecord Reference
}

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.

func (*StatelessCallResult) Read

func (r *StatelessCallResult) Read(p []byte) (n int, err error)

Read allows to read Result's resultMemory.

func (*StatelessCallResult) Write

func (r *StatelessCallResult) Write(p []byte) (n int, err error)

Write allows to write to Request's paramMemory.

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 TypeID added in v0.0.2

type TypeID uint32

TypeID encodes a record object type.

func (TypeID) WriteHash added in v0.0.2

func (id TypeID) WriteHash(w io.Writer)

WriteHash implements hash.Writer interface.

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   [core.RecordHashSize]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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL