xmodel

package
v0.0.0-...-56f3d1a Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 16 Imported by: 6

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 KVEngineType = "default"

KVEngineType KV storage type

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 []*kledger.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 []*kledger.VersionedData) []*protos.TxInputExt

GetTxInputs get transaction inputs

func GetTxOutputs

func GetTxOutputs(pds []*kledger.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 *kledger.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 *kledger.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 kledger.XMReader) *xMSnapshotReader

func ParseContractUtxoInputs

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

ParseContractUtxoInputs parse contract utxo inputs from tx write sets

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 XMIterator

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

XMIterator data structure for XModel Iterator

func (*XMIterator) Close

func (di *XMIterator) Close()

Release release XMIterator

func (*XMIterator) Error

func (di *XMIterator) Error() error

Error return error info for XMIterator

func (*XMIterator) Key

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

Key get key for XMIterator

func (*XMIterator) Next

func (di *XMIterator) Next() bool

Next check if next element exist

func (*XMIterator) Value

func (di *XMIterator) Value() *kledger.VersionedData

Data get data pointer to VersionedData for XMIterator

type XModel

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

XModel xmodel data structure

func NewXModel

func NewXModel(sctx *context.StateCtx, stateDB kvdb.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) (kledger.XMReader, error)

func (*XModel) CreateXMSnapshotReader

func (s *XModel) CreateXMSnapshotReader(blkId []byte) (kledger.XMSnapshotReader, error)

func (*XModel) DoTx

func (s *XModel) DoTx(tx *pb.Transaction, batch kvdb.Batch) error

DoTx running a transaction and update extUtxoTable

func (*XModel) Get

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

Get get value for specific key, return value with version

func (*XModel) GetFromLedger

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

GetFromLedger get data directely from ledger

func (*XModel) GetUncommited

func (s *XModel) GetUncommited(bucket string, key []byte) (*kledger.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) (*kledger.VersionedData, bool, error)

GetWithTxStatus likes Get but also return tx status information

func (*XModel) QueryBlock

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

QueryBlock query block from ledger

func (*XModel) QueryTx

func (s *XModel) QueryTx(txid []byte) (*pb.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) (kledger.XMIterator, error)

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

func (*XModel) UndoTx

func (s *XModel) UndoTx(tx *pb.Transaction, batch kvdb.Batch) error

UndoTx rollback a transaction and update extUtxoTable

Jump to

Keyboard shortcuts

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