state

package
v0.0.0-...-1c999d7 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TraceOptionNone = iota
	TraceOptionAll
	TraceOptionFailedConstraints
)

Variables

Functions

func InitLedgerState

func InitLedgerState(par InitLedgerStateParams) common.VCommitment

InitLedgerState initializes origin ledger state in the empty store If FinalityGadgetAddress != nil, it also creates chain output for the finality gadget Returns root commitment to the genesis ledger state

func PathToString

func PathToString(path []byte) string

Types

type InitLedgerStateParams

type InitLedgerStateParams struct {
	Store                 common.KVWriter
	Identity              []byte
	InitialSupply         uint64
	GenesisAddress        constraints.AddressED25519
	Timestamp             uint32
	FinalityGadgetAddress constraints.AddressED25519 // FG output is created when not nil
}

type Readable

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

Readable is a read-only ledger state, with the particular root

func NewReadable

func NewReadable(store common.KVReader, root common.VCommitment, clearCacheAtSize ...int) (*Readable, error)

NewReadable creates read-only ledger state with the given root

func (*Readable) GetUTXO

func (r *Readable) GetUTXO(oid *ledger.OutputID) ([]byte, bool)

func (*Readable) HasTransactionOutputs

func (r *Readable) HasTransactionOutputs(txid *ledger.TransactionID, indexMap ...map[byte]struct{}) (bool, bool)

type Transaction

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

Transaction provides access to the tree of transferable transaction

func TransactionFromTransferableBytes

func TransactionFromTransferableBytes(txBytes []byte, timestampBoundsInclusive ...uint32) (*Transaction, error)

func (*Transaction) EssenceBytes

func (tx *Transaction) EssenceBytes() []byte

func (*Transaction) MustForEachEndorsement

func (tx *Transaction) MustForEachEndorsement(fun func(idx byte, txid ledger.TransactionID) bool)

func (*Transaction) MustForEachInput

func (tx *Transaction) MustForEachInput(fun func(i byte, oid *ledger.OutputID) bool)

func (*Transaction) NumInputs

func (tx *Transaction) NumInputs() int

func (*Transaction) NumProducedOutputs

func (tx *Transaction) NumProducedOutputs() int

func (*Transaction) OutputAt

func (tx *Transaction) OutputAt(idx byte) []byte

func (*Transaction) SenderAddress

func (tx *Transaction) SenderAddress() constraints.AddressED25519

func (*Transaction) Timestamp

func (tx *Transaction) Timestamp() uint32

type TransactionContext

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

TransactionContext is a data structure, which contains transferable transaction, consumed outputs and constraint library

func TransactionContextFromTransaction

func TransactionContextFromTransaction(tx *Transaction, txid *ledger.TransactionID, ledgerState ledger.StateReader, traceOption ...int) (*TransactionContext, error)

func TransactionContextFromTransferableBytes

func TransactionContextFromTransferableBytes(txBytes []byte, ledgerState ledger.StateReader, traceOption ...int) (*TransactionContext, error)

TransactionContextFromTransferableBytes constructs lazytree from transaction bytes and consumed outputs

func TransactionContextFromTransferableBytesWithTxID

func TransactionContextFromTransferableBytesWithTxID(txBytes []byte, txid *ledger.TransactionID, ledgerState ledger.StateReader, traceOption ...int) (*TransactionContext, error)

func (*TransactionContext) ConsumedOutputData

func (v *TransactionContext) ConsumedOutputData(idx byte) []byte

func (*TransactionContext) ForEachInputID

func (v *TransactionContext) ForEachInputID(fun func(idx byte, oid *ledger.OutputID) bool)

func (*TransactionContext) InputCommitment

func (v *TransactionContext) InputCommitment() []byte

func (*TransactionContext) InputID

func (v *TransactionContext) InputID(idx byte) ledger.OutputID

func (*TransactionContext) NumInputs

func (v *TransactionContext) NumInputs() int

func (*TransactionContext) NumProducedOutputs

func (v *TransactionContext) NumProducedOutputs() int

func (*TransactionContext) ProducedOutputData

func (v *TransactionContext) ProducedOutputData(idx byte) []byte

func (*TransactionContext) Signature

func (v *TransactionContext) Signature() []byte

func (*TransactionContext) TimestampData

func (v *TransactionContext) TimestampData() ([]byte, uint32)

func (*TransactionContext) TransactionBytes

func (v *TransactionContext) TransactionBytes() []byte

func (*TransactionContext) TransactionID

func (v *TransactionContext) TransactionID() *ledger.TransactionID

func (*TransactionContext) UnlockData

func (v *TransactionContext) UnlockData(idx byte) []byte

func (*TransactionContext) UnlockParams

func (v *TransactionContext) UnlockParams(consumedOutputIdx, constraintIdx byte) []byte

func (*TransactionContext) Validate

func (v *TransactionContext) Validate() ([]*indexer.Command, error)

type Updatable

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

Updatable is an updatable ledger state, with the particular root Suitable for chained updates

func NewUpdatable

func NewUpdatable(store ledger.StateStore, root common.VCommitment) (*Updatable, error)

NewUpdatable creates updatable state with the given root. After updated, the root changes. Suitable for chained updates of the ledger state

func (*Updatable) Readable

func (u *Updatable) Readable() *Readable

func (*Updatable) Root

func (u *Updatable) Root() common.VCommitment

Root return the current root

func (*Updatable) Update

func (u *Updatable) Update(txBytes []byte, traceOption ...int) ([]*indexer.Command, error)

Update updates/mutates the ledger state by transaction

Jump to

Keyboard shortcuts

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