model

package
v0.0.0-...-b124b1e Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const BucketSeperator = "/"

BucketSeperator separator between bucket and raw key

View Source
const DelFlag = "\x00"

DelFlag delete flag

View Source
const (

	// TransientBucket is the name of bucket that only appears in tx output set
	// but does't persists in xmodel
	TransientBucket = "$transient"
)

Variables

This section is empty.

Functions

func Equal

func Equal(pd, vpd []*ledger.PureData) bool

Equal check if two PureData object equal

func GenWriteKeyWithPrefix

func GenWriteKeyWithPrefix(txOutputExt *protos.TxOutputExt) string

GenWriteKeyWithPrefix gen write key with perfix

func GetTxInputs

func GetTxInputs(vds []*ledger.VersionedData) []*protos.TxInputExt

GetTxInputs get transaction inputs

func GetTxOutputs

func GetTxOutputs(pds []*ledger.PureData) []*protos.TxOutputExt

GetTxOutputs get transaction outputs

func GetTxidFromVersion

func GetTxidFromVersion(version string) []byte

GetTxidFromVersion parse version and fetch txid from version string

func GetVersion

func GetVersion(vd *ledger.VersionedData) string

GetVersion get VersionedData's version, if refTxid is nil, return ""

func GetVersionOfTxInput

func GetVersionOfTxInput(txIn *protos.TxInputExt) string

GetVersionOfTxInput get version of TxInput

func IsEmptyVersionedData

func IsEmptyVersionedData(vd *ledger.VersionedData) bool

IsEmptyVersionedData check if VersionedData is empty

func MakeRawKey

func MakeRawKey(bucket string, key []byte) []byte

MakeRawKey make key with bucket and raw key

func MakeVersion

func MakeVersion(txid []byte, offset int32) string

MakeVersion generate a version by txid and offset, version = txid_offset

func MarshalMessages

func MarshalMessages(msgs interface{}) ([]byte, error)

MarshalMessages marshal protobuf message slice

func NewXMSnapshotReader

func NewXMSnapshotReader(xMReader ledger.XReader) *xMSnapshotReader

func ParseContractUtxoInputs

func ParseContractUtxoInputs(tx *protos.Transaction) ([]*protos.TxInput, error)

ParseContractUtxoInputs parse contract utxo inputs from tx write sets

func UnmarshalMerge

func UnmarshalMerge(b []byte, m proto.Message) error

UnmarshalMerge parses a wire-format message in b and places the decoded results in m.

func UnmsarshalMessages

func UnmsarshalMessages(p []byte, x interface{}) error

UnmsarshalMessages unmarshal protobuf messages to slice, x must be a pointer to message slice

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer is a buffer for encoding and decoding the protobuf wire format. It may be reused between invocations to reduce memory usage.

func NewBuffer

func NewBuffer(buf []byte) *Buffer

NewBuffer allocates a new Buffer initialized with buf, where the contents of buf are considered the unread portion of the buffer.

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

Bytes returns the internal buffer.

func (*Buffer) DecodeMessage

func (b *Buffer) DecodeMessage(m proto.Message) error

DecodeMessage consumes a length-prefixed message from the buffer. It does not reset m before unmarshaling.

func (*Buffer) DecodeRawBytes

func (b *Buffer) DecodeRawBytes(alloc bool) ([]byte, error)

DecodeRawBytes consumes a length-prefixed raw bytes from the buffer. If alloc is specified, it returns a copy the raw bytes rather than a sub-slice of the buffer.

func (*Buffer) DecodeVarint

func (b *Buffer) DecodeVarint() (uint64, error)

DecodeVarint consumes an encoded unsigned varint from the buffer.

func (*Buffer) EncodeMessage

func (b *Buffer) EncodeMessage(m proto.Message) error

EncodeMessage appends a length-prefixed encoded message to the buffer.

func (*Buffer) EncodeVarint

func (b *Buffer) EncodeVarint(v uint64) error

EncodeVarint appends an unsigned varint encoding to the buffer.

func (*Buffer) Reset

func (b *Buffer) Reset()

Reset clears the internal buffer of all written and unread data.

func (*Buffer) SetBuf

func (b *Buffer) SetBuf(buf []byte)

SetBuf sets buf as the internal buffer, where the contents of buf are considered the unread portion of the buffer.

func (*Buffer) Unread

func (b *Buffer) Unread() []byte

Unread returns the unread portion of the buffer.

type ListCursor

type ListCursor struct {
	// contains filtered or unexported fields
}

type XIterator

type XIterator struct {
	// contains filtered or unexported fields
}

XIterator data structure for XModel Iterator

func (*XIterator) Close

func (di *XIterator) Close()

Release release XIterator

func (*XIterator) Error

func (di *XIterator) Error() error

Error return error info for XIterator

func (*XIterator) Key

func (di *XIterator) Key() []byte

Key get key for XIterator

func (*XIterator) Next

func (di *XIterator) Next() bool

Next check if next element exist

func (*XIterator) Value

func (di *XIterator) Value() *ledger.VersionedData

Data get data pointer to VersionedData for XIterator

type XModel

type XModel struct {
	// contains filtered or unexported fields
}

XModel xmodel data structure

func NewXModel

func NewXModel(sctx *base.StateCtx, stateDB storage.Database) (*XModel, error)

NewXuperModel new an instance of XModel

func (*XModel) BucketCacheDelete

func (s *XModel) BucketCacheDelete(bucket, version string)

BucketCacheDelete gen write key with perfix

func (*XModel) CleanCache

func (s *XModel) CleanCache()

CleanCache clear batchCache and lastBatch

func (*XModel) CreateSnapshot

func (s *XModel) CreateSnapshot(blkId []byte) (ledger.XReader, error)

func (*XModel) CreateXMSnapshotReader

func (s *XModel) CreateXMSnapshotReader(blkId []byte) (ledger.SnapshotReader, error)

func (*XModel) DoTx

func (s *XModel) DoTx(tx *protos.Transaction, batch storage.Batch) error

DoTx running a transaction and update extUtxoTable

func (*XModel) Get

func (s *XModel) Get(bucket string, key []byte) (*ledger.VersionedData, error)

Get get value for specific key, return value with version

func (*XModel) GetFromLedger

func (s *XModel) GetFromLedger(txin *protos.TxInputExt) (*ledger.VersionedData, error)

GetFromLedger get data directely from ledger

func (*XModel) GetUncommited

func (s *XModel) GetUncommited(bucket string, key []byte) (*ledger.VersionedData, error)

GetUncommited get value for specific key, return the value with version, even it is in batch cache

func (*XModel) GetWithTxStatus

func (s *XModel) GetWithTxStatus(bucket string, key []byte) (*ledger.VersionedData, bool, error)

GetWithTxStatus likes Get but also return tx status information

func (*XModel) QueryBlock

func (s *XModel) QueryBlock(blockid []byte) (*protos.InternalBlock, error)

QueryBlock query block from ledger

func (*XModel) QueryTx

func (s *XModel) QueryTx(txid []byte) (*protos.Transaction, bool, error)

QueryTx query transaction including unconfirmed table and confirmed table

func (*XModel) Select

func (s *XModel) Select(bucket string, startKey []byte, endKey []byte) (ledger.XIterator, error)

Select select all kv from a bucket, can set key range, left closed, right opend

func (*XModel) UndoTx

func (s *XModel) UndoTx(tx *protos.Transaction, batch storage.Batch) error

UndoTx rollback a transaction and update extUtxoTable

type XSnapshot

type XSnapshot struct {
	// contains filtered or unexported fields
}

func (*XSnapshot) Get

func (t *XSnapshot) Get(bucket string, key []byte) (*ledger.VersionedData, error)

func (*XSnapshot) GetUncommited

func (t *XSnapshot) GetUncommited(bucket string, key []byte) (*ledger.VersionedData, error)

func (*XSnapshot) Select

func (t *XSnapshot) Select(bucket string, startKey []byte, endKey []byte) (ledger.XIterator, error)

Jump to

Keyboard shortcuts

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