record

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package record contains code and types for storage records manipulation.

Index

Constants

View Source
const TypeIDSize = 4

TypeIDSize is a size of TypeID type.

Variables

This section is empty.

Functions

func ID2Bytes added in v0.0.2

func ID2Bytes(id ID) []byte

ID2Bytes converts ID struct to it's byte representation.

func SerializeRecord added in v0.6.1

func SerializeRecord(rec Record) []byte

SerializeRecord returns binary representation of provided record.

func SerializeType added in v0.6.1

func SerializeType(id TypeID) []byte

SerializeType returns binary representation of provided type.

Types

type CallRequest

type CallRequest struct {
	Payload []byte
}

CallRequest is a contract execution request.

func (*CallRequest) GetPayload added in v0.5.0

func (r *CallRequest) GetPayload() []byte

GetPayload returns payload. Required for Record interface implementation.

func (*CallRequest) Type added in v0.6.1

func (r *CallRequest) Type() TypeID

Type implementation of Record interface.

func (*CallRequest) WriteHashData added in v0.6.1

func (r *CallRequest) WriteHashData(w io.Writer) (int, error)

WriteHashData writes record data to provided writer. This data is used to calculate record's hash.

type ChildRecord added in v0.5.0

type ChildRecord struct {
	PrevChild *ID

	Ref Reference // Reference to the child's head.
}

ChildRecord is a child activation record. Its used for children iterating.

func (*ChildRecord) Type added in v0.6.1

func (r *ChildRecord) Type() TypeID

Type implementation of Record interface.

func (*ChildRecord) WriteHashData added in v0.6.1

func (r *ChildRecord) WriteHashData(w io.Writer) (int, error)

WriteHashData writes record data to provided writer. This data is used to calculate record's hash.

type ClassActivateRecord

type ClassActivateRecord struct {
	ResultRecord
	ClassStateRecord
}

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

func (*ClassActivateRecord) Type added in v0.6.1

func (r *ClassActivateRecord) Type() TypeID

Type implementation of Record interface.

func (*ClassActivateRecord) WriteHashData added in v0.6.1

func (r *ClassActivateRecord) WriteHashData(w io.Writer) (int, error)

WriteHashData writes record data to provided writer. This data is used to calculate record's hash.

type ClassAmendRecord

type ClassAmendRecord struct {
	ResultRecord
	ClassStateRecord

	PrevState ID
}

ClassAmendRecord is an amendment record for classes.

func (*ClassAmendRecord) Type added in v0.6.1

func (r *ClassAmendRecord) Type() TypeID

Type implementation of Record interface.

func (*ClassAmendRecord) WriteHashData added in v0.6.1

func (r *ClassAmendRecord) WriteHashData(w io.Writer) (int, error)

WriteHashData writes record data to provided writer. This data is used to calculate record's hash.

type ClassState added in v0.3.0

type ClassState interface {
	// IsDeactivation determines if current state is deactivation.
	IsDeactivation() bool
	// GetCode returns state code.
	GetCode() *Reference
	// GetMachineType returns state code machine type.
	GetMachineType() core.MachineType
}

ClassState is common class state record.

type ClassStateRecord added in v0.6.1

type ClassStateRecord struct {
	Code        Reference
	MachineType core.MachineType
}

ClassStateRecord is a record containing data for a class state.

func (*ClassStateRecord) GetCode added in v0.6.1

func (r *ClassStateRecord) GetCode() *Reference

GetCode returns state code.

func (*ClassStateRecord) GetMachineType added in v0.6.1

func (r *ClassStateRecord) GetMachineType() core.MachineType

GetMachineType returns state code machine type.

func (*ClassStateRecord) IsDeactivation added in v0.6.1

func (r *ClassStateRecord) IsDeactivation() bool

IsDeactivation determines if current state is deactivation.

type CodeRecord

type CodeRecord struct {
	ResultRecord

	Code        []byte
	MachineType core.MachineType
}

CodeRecord is a code storage record.

func (*CodeRecord) Type added in v0.6.1

func (r *CodeRecord) Type() TypeID

Type implementation of Record interface.

func (*CodeRecord) WriteHashData added in v0.6.1

func (r *CodeRecord) WriteHashData(w io.Writer) (int, error)

WriteHashData writes record data to provided writer. This data is used to calculate record's hash.

type DeactivationRecord

type DeactivationRecord struct {
	ResultRecord
	PrevState ID
}

DeactivationRecord marks targeted object as disabled.

func (*DeactivationRecord) GetCode added in v0.3.0

func (*DeactivationRecord) GetCode() *Reference

GetCode returns state code.

func (*DeactivationRecord) GetMachineType added in v0.6.1

func (*DeactivationRecord) GetMachineType() core.MachineType

GetMachineType returns state code machine type.

func (*DeactivationRecord) GetMemory added in v0.3.0

func (*DeactivationRecord) GetMemory() []byte

GetMemory returns state memory.

func (*DeactivationRecord) IsAmend added in v0.3.0

func (*DeactivationRecord) IsAmend() bool

IsAmend determines if current state is amend.

func (*DeactivationRecord) IsDeactivation added in v0.3.0

func (*DeactivationRecord) IsDeactivation() bool

IsDeactivation determines if current state is deactivation.

func (*DeactivationRecord) Type added in v0.6.1

func (r *DeactivationRecord) Type() TypeID

Type implementation of Record interface.

func (*DeactivationRecord) WriteHashData added in v0.6.1

func (r *DeactivationRecord) WriteHashData(w io.Writer) (int, error)

WriteHashData writes record data to provided writer. This data is used to calculate record's hash.

type GenesisRecord added in v0.6.0

type GenesisRecord struct {
}

GenesisRecord is the first record created on storage. It's used to link root objects to it.

func (*GenesisRecord) GetCode added in v0.6.0

func (*GenesisRecord) GetCode() *Reference

GetCode returns state code.

func (*GenesisRecord) GetMemory added in v0.6.0

func (*GenesisRecord) GetMemory() []byte

GetMemory returns state memory.

func (*GenesisRecord) IsAmend added in v0.6.0

func (*GenesisRecord) IsAmend() bool

IsAmend determines if current state is amend.

func (*GenesisRecord) IsDeactivation added in v0.6.0

func (*GenesisRecord) IsDeactivation() bool

IsDeactivation determines if current state is deactivation.

func (*GenesisRecord) Type added in v0.6.1

func (r *GenesisRecord) Type() TypeID

Type implementation of Record interface.

func (*GenesisRecord) WriteHashData added in v0.6.1

func (r *GenesisRecord) WriteHashData(w io.Writer) (int, error)

WriteHashData writes record data to provided writer. This data is used to calculate record's hash.

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) CoreID added in v0.5.0

func (id *ID) CoreID() *core.RecordID

CoreID generates Reference byte representation (key without prefix).

func (ID) IsEqual added in v0.0.2

func (id ID) IsEqual(id2 ID) bool

IsEqual checks equality of IDs.

type ObjectActivateRecord

type ObjectActivateRecord struct {
	ResultRecord
	ObjectStateRecord

	Class    Reference
	Parent   Reference
	Delegate bool
}

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

func (*ObjectActivateRecord) Type added in v0.6.1

func (r *ObjectActivateRecord) Type() TypeID

Type implementation of Record interface.

func (*ObjectActivateRecord) WriteHashData added in v0.6.1

func (r *ObjectActivateRecord) WriteHashData(w io.Writer) (int, error)

WriteHashData writes record data to provided writer. This data is used to calculate record's hash.

type ObjectAmendRecord

type ObjectAmendRecord struct {
	ResultRecord
	ObjectStateRecord

	PrevState ID
}

ObjectAmendRecord is an amendment record for objects.

func (*ObjectAmendRecord) Type added in v0.6.1

func (r *ObjectAmendRecord) Type() TypeID

Type implementation of Record interface.

func (*ObjectAmendRecord) WriteHashData added in v0.6.1

func (r *ObjectAmendRecord) WriteHashData(w io.Writer) (int, error)

WriteHashData writes record data to provided writer. This data is used to calculate record's hash.

type ObjectState added in v0.3.0

type ObjectState interface {
	// IsDeactivation determines if current state is deactivation.
	IsDeactivation() bool
	// GetMemory returns state memory.
	GetMemory() []byte
}

ObjectState is common object state record.

type ObjectStateRecord added in v0.6.1

type ObjectStateRecord struct {
	Memory []byte
}

ObjectStateRecord is a record containing data for an object state.

func (*ObjectStateRecord) GetMemory added in v0.6.1

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

GetMemory returns state memory.

func (*ObjectStateRecord) IsDeactivation added in v0.6.1

func (r *ObjectStateRecord) IsDeactivation() bool

IsDeactivation determines if current state is deactivation.

type PulseRecord added in v0.6.0

type PulseRecord struct {
	PrevPulse          core.PulseNumber
	Entropy            core.Entropy
	PredictedNextPulse core.PulseNumber
}

PulseRecord is a record containing pulse info.

type Record

type Record interface {
	// Type returns record type.
	Type() TypeID
	// WriteHashData writes record data to provided writer. This data is used to calculate record's hash.
	WriteHashData(w io.Writer) (int, error)
}

Record is base interface for all records.

func DeserializeRecord added in v0.6.1

func DeserializeRecord(buf []byte) Record

DeserializeRecord returns record decoded from bytes.

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.

func (Reference) String added in v0.4.0

func (ref Reference) String() string

String returns Base58 string representation of Reference.

type Request added in v0.5.0

type Request interface {
	Record
	GetPayload() []byte
}

Request extends Record interface with GetPayload method.

type ResultRecord

type ResultRecord struct {
	Domain  Reference
	Request Reference
}

ResultRecord is a record which is created in response to a request.

type TypeID added in v0.0.2

type TypeID uint32

TypeID encodes a record object type.

func DeserializeType added in v0.6.1

func DeserializeType(buf []byte) TypeID

DeserializeType returns type from provided binary representation.

func (TypeID) WriteHash added in v0.0.2

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

WriteHashData implements hash.Writer interface.

type TypeRecord added in v0.0.5

type TypeRecord struct {
	ResultRecord

	TypeDeclaration []byte
}

TypeRecord is a code interface declaration.

func (*TypeRecord) Type added in v0.6.1

func (r *TypeRecord) Type() TypeID

Type implementation of Record interface.

func (*TypeRecord) WriteHashData added in v0.6.1

func (r *TypeRecord) WriteHashData(w io.Writer) (int, error)

WriteHashData writes record data to provided writer. This data is used to calculate record's hash.

Jump to

Keyboard shortcuts

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