record

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package record contains code and types for storage records manipulation.

Index

Constants

View Source
const (
	// StateUndefined is used for special cases.
	StateUndefined = State(iota)
	// StateActivation means it's an activation record.
	StateActivation
	// StateAmend means it's an amend record.
	StateAmend
	// StateDeactivation means it's a deactivation record.
	StateDeactivation
)
View Source
const TypeIDSize = 4

TypeIDSize is a size of TypeID type.

Variables

This section is empty.

Functions

func CalculateIDForBlob

func CalculateIDForBlob(scheme core.PlatformCryptographyScheme, pulseNumber core.PulseNumber, blob []byte) *core.RecordID

CalculateIDForBlob calculate id for blob with using current pulse number

func NewRecordIDFromRecord

func NewRecordIDFromRecord(scheme core.PlatformCryptographyScheme, pulse core.PulseNumber, rec Record) *core.RecordID

func Registered added in v0.8.0

func Registered() map[TypeID]Record

Registered returns records by type.

func SerializeRecord

func SerializeRecord(rec Record) []byte

SerializeRecord returns binary representation of provided record.

func SerializeType

func SerializeType(id TypeID) []byte

SerializeType returns binary representation of provided type.

Types

type ChildRecord

type ChildRecord struct {
	PrevChild *core.RecordID

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

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

func (*ChildRecord) WriteHashData

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 CodeRecord

type CodeRecord struct {
	SideEffectRecord

	Code        *core.RecordID
	MachineType core.MachineType
}

CodeRecord is a code storage record.

func (*CodeRecord) WriteHashData

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 {
	SideEffectRecord
	PrevState core.RecordID
}

DeactivationRecord marks targeted object as disabled.

func (*DeactivationRecord) GetImage

func (r *DeactivationRecord) GetImage() *core.RecordRef

GetImage returns state code.

func (*DeactivationRecord) GetIsPrototype

func (r *DeactivationRecord) GetIsPrototype() bool

GetIsPrototype returns state code.

func (*DeactivationRecord) GetMachineType

func (*DeactivationRecord) GetMachineType() core.MachineType

GetMachineType returns state code machine type.

func (*DeactivationRecord) GetMemory

func (*DeactivationRecord) GetMemory() *core.RecordID

GetMemory returns state memory.

func (*DeactivationRecord) PrevStateID

func (r *DeactivationRecord) PrevStateID() *core.RecordID

PrevStateID returns previous state id.

func (*DeactivationRecord) State

func (r *DeactivationRecord) State() State

State returns state id.

func (*DeactivationRecord) WriteHashData

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

type GenesisRecord struct {
}

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

func (*GenesisRecord) GetImage

func (*GenesisRecord) GetImage() *core.RecordRef

GetImage returns state code.

func (*GenesisRecord) GetIsPrototype

func (*GenesisRecord) GetIsPrototype() bool

GetIsPrototype returns state code.

func (*GenesisRecord) GetMemory

func (*GenesisRecord) GetMemory() *core.RecordID

GetMemory returns state memory.

func (*GenesisRecord) PrevStateID

func (r *GenesisRecord) PrevStateID() *core.RecordID

PrevStateID returns previous state id.

func (*GenesisRecord) State

func (r *GenesisRecord) State() State

State returns state id.

func (*GenesisRecord) WriteHashData

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 JetRecord

type JetRecord struct {
}

JetRecord represents Jet.

func (*JetRecord) WriteHashData

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

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

type ObjectActivateRecord

type ObjectActivateRecord struct {
	SideEffectRecord
	ObjectStateRecord

	Parent     core.RecordRef
	IsDelegate bool
}

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

func (*ObjectActivateRecord) PrevStateID

func (r *ObjectActivateRecord) PrevStateID() *core.RecordID

PrevStateID returns previous state id.

func (*ObjectActivateRecord) State

func (r *ObjectActivateRecord) State() State

State returns state id.

func (*ObjectActivateRecord) WriteHashData

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 {
	SideEffectRecord
	ObjectStateRecord

	PrevState core.RecordID
}

ObjectAmendRecord is an amendment record for objects.

func (*ObjectAmendRecord) PrevStateID

func (r *ObjectAmendRecord) PrevStateID() *core.RecordID

PrevStateID returns previous state id.

func (*ObjectAmendRecord) State

func (r *ObjectAmendRecord) State() State

State returns state id.

func (*ObjectAmendRecord) WriteHashData

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

type ObjectState interface {
	// State returns state id.
	State() State
	// GetImage returns state code.
	GetImage() *core.RecordRef
	// GetIsPrototype returns state code.
	GetIsPrototype() bool
	// GetMemory returns state memory.
	GetMemory() *core.RecordID
	// PrevStateID returns previous state id.
	PrevStateID() *core.RecordID
}

ObjectState is common object state record.

type ObjectStateRecord

type ObjectStateRecord struct {
	Memory      *core.RecordID
	Image       core.RecordRef // If code or prototype object reference.
	IsPrototype bool           // If true, Image should point to a prototype object. Otherwise to a code.
}

ObjectStateRecord is a record containing data for an object state.

func (*ObjectStateRecord) GetImage

func (r *ObjectStateRecord) GetImage() *core.RecordRef

GetImage returns state code.

func (*ObjectStateRecord) GetIsPrototype

func (r *ObjectStateRecord) GetIsPrototype() bool

GetIsPrototype returns state code.

func (*ObjectStateRecord) GetMemory

func (r *ObjectStateRecord) GetMemory() *core.RecordID

GetMemory returns state memory.

type Record

type Record interface {
	// 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

func DeserializeRecord(buf []byte) Record

DeserializeRecord returns record decoded from bytes.

func RecordFromType added in v0.8.0

func RecordFromType(i TypeID) Record

type Request

type Request interface {
	Record
	GetPayload() []byte
	GetObject() core.RecordID
}

Request extends Record interface with GetPayload method.

type RequestRecord

type RequestRecord struct {
	Parcel      []byte
	MessageHash []byte
	Object      core.RecordID
}

RequestRecord is a contract execution request.

func (*RequestRecord) GetObject

func (r *RequestRecord) GetObject() core.RecordID

GetObject returns request object.

func (*RequestRecord) GetPayload

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

GetPayload returns payload. Required for Record interface implementation.

func (*RequestRecord) WriteHashData

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

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

type ResultRecord

type ResultRecord struct {
	Object  core.RecordID
	Request core.RecordRef
	Payload []byte
}

ResultRecord represents result of a VM method.

func (*ResultRecord) WriteHashData

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

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

type SideEffectRecord

type SideEffectRecord struct {
	Domain  core.RecordRef
	Request core.RecordRef
}

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

type State

type State int

State is a state of lifeline records.

type TypeID

type TypeID uint32

TypeID encodes a record object type.

func DeserializeType

func DeserializeType(buf []byte) TypeID

DeserializeType returns type from provided binary representation.

func TypeFromRecord added in v0.8.0

func TypeFromRecord(generic Record) TypeID

func (TypeID) String

func (i TypeID) String() string

type TypeRecord

type TypeRecord struct {
	SideEffectRecord

	TypeDeclaration []byte
}

TypeRecord is a code interface declaration.

func (*TypeRecord) WriteHashData

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