Documentation ¶
Index ¶
- Constants
- Variables
- func AbsoluteStrongFinalityCoverageThreshold(supply uint64, numerator, denominator int) uint64
- func BalanceOnChainOutput(rdr StateIndexReader, chainID *ledger.ChainID) uint64
- func BalanceOnLock(rdr StateIndexReader, account ledger.Accountable) (uint64, int)
- func BranchKnowsTransaction(branchID, txid *ledger.TransactionID, getStore func() common.KVReader) bool
- func CommitEmptyRootWithLedgerIdentity(par ledger.IdentityData, store StateStore) (common.VCommitment, error)
- func FetchEarliestSlot(store common.KVReader) ledger.Slot
- func FetchLatestBranchTransactionIDs(store StateStoreReader) []ledger.TransactionID
- func FetchLatestCommittedSlot(store common.KVReader) ledger.Slot
- func FetchSnapshotBranchID(store common.KVTraversableReader) ledger.TransactionID
- func FindLatestHealthySlot(store StateStoreReader, fraction global.Fraction) (ledger.Slot, bool)
- func FirstHealthySlotIsNotBefore(store StateStoreReader, refSlot ledger.Slot, fraction global.Fraction) (ret bool)
- func InitLedgerFromStore(stateStore StateStore, verbose ...bool)
- func InitStateStore(par ledger.IdentityData, store StateStore) (ledger.ChainID, common.VCommitment)
- func IterateBranchChainBack(store StateStoreReader, branch *BranchData, ...)
- func IterateRootRecords(store common.Traversable, ...)
- func IterateSlotsBack(store StateStoreReader, fun func(slot ledger.Slot, roots []RootRecord) bool)
- func LedgerIdentityBytesFromRoot(store StateStoreReader, root common.VCommitment) []byte
- func LedgerIdentityBytesFromStore(store StateStore) []byte
- func MakeTree(stateStore StateStore, slots ...int) graph.Graph[string, string]
- func PartitionToString(p byte) string
- func RootHasTransaction(store common.KVReader, root common.VCommitment, txid *ledger.TransactionID) bool
- func SaveBranchTree(stateStore StateStore, fname string, slotsBack ...int)
- func ScanGenesisState(stateStore StateStore) (*ledger.IdentityData, common.VCommitment, error)
- func UpdateTrie(trie *immutable.TrieUpdatable, mut *Mutations) (err error)
- func ValidInclusionThresholdFraction(numerator, denominator int) bool
- func WriteEarliestSlotRecord(w common.KVWriter, slot ledger.Slot)
- func WriteLatestSlotRecord(w common.KVWriter, slot ledger.Slot)
- func WriteRootRecord(w common.KVWriter, branchTxID ledger.TransactionID, rootData RootRecord)
- type AccountInfo
- type BranchData
- func CheckTransactionInLRB(store StateStoreReader, txid ledger.TransactionID, maxDepth int, ...) (lrb *BranchData, foundAtDepth int)
- func FetchBranchData(store common.KVReader, branchTxID ledger.TransactionID) (BranchData, bool)
- func FetchBranchDataByRoot(store common.KVReader, rootData RootRecord) BranchData
- func FetchBranchDataMulti(store common.KVReader, rootData ...RootRecord) []*BranchData
- func FetchHeaviestBranchChainNSlotsBack(store StateStoreReader, nBack int) []*BranchData
- func FetchLatestBranches(store StateStoreReader) []*BranchData
- func FindFirstBranch(store StateStoreReader, filter func(branch *BranchData) bool) *BranchData
- func FindLatestReliableBranch(store StateStoreReader, fraction global.Fraction) *BranchData
- func FindLatestReliableBranchAndNSlotsBack(store StateStoreReader, n int, fraction global.Fraction) (ret *BranchData)
- func FindLatestReliableBranchWithSequencerID(store StateStoreReader, seqID ledger.ChainID, fraction global.Fraction) (ret *BranchData)
- func GetMainChain(store StateStoreReader, fraction global.Fraction, max ...int) ([]*BranchData, error)
- type BranchDataJSONAble
- type ChainRecordInfo
- type IndexedStateReader
- type LockedAccountInfo
- type Mutations
- func (mut *Mutations) InsertAddOutputMutation(id ledger.OutputID, o *ledger.Output)
- func (mut *Mutations) InsertAddTxMutation(id ledger.TransactionID, slot ledger.Slot, lastOutputIndex byte)
- func (mut *Mutations) InsertDelChainMutation(id ledger.ChainID)
- func (mut *Mutations) InsertDelOutputMutation(id ledger.OutputID)
- func (mut *Mutations) Len() int
- func (mut *Mutations) Lines(prefix ...string) *lines.Lines
- func (mut *Mutations) Sort() *Mutations
- type Readable
- func (r *Readable) AccountsByLocks() map[string]LockedAccountInfo
- func (r *Readable) GetStem() (ledger.Slot, []byte)
- func (r *Readable) GetUTXO(oid *ledger.OutputID) ([]byte, bool)
- func (r *Readable) GetUTXOForChainID(id *ledger.ChainID) (*ledger.OutputDataWithID, error)
- func (r *Readable) GetUTXOIDsInAccount(addr ledger.AccountID) ([]ledger.OutputID, error)
- func (r *Readable) GetUTXOsInAccount(addr ledger.AccountID) ([]*ledger.OutputDataWithID, error)
- func (r *Readable) HasUTXO(oid *ledger.OutputID) bool
- func (r *Readable) IterateChainTips(fun func(chainID ledger.ChainID, oid ledger.OutputID) bool) error
- func (r *Readable) IterateKnownCommittedTransactions(fun func(txid *ledger.TransactionID, slot ledger.Slot) bool, ...)
- func (r *Readable) IterateUTXOIDsInAccount(addr ledger.AccountID, fun func(oid ledger.OutputID) bool) (err error)
- func (r *Readable) IterateUTXOsInAccount(addr ledger.AccountID, fun func(oid ledger.OutputID, odata []byte) bool) (err error)
- func (r *Readable) Iterator(prefix []byte) common.KVIterator
- func (r *Readable) KnowsCommittedTransaction(txid *ledger.TransactionID) bool
- func (r *Readable) MustLedgerIdentityBytes() []byte
- func (r *Readable) Root() common.VCommitment
- type RootRecord
- func FetchAllRootRecords(store common.Traversable) []RootRecord
- func FetchAnyLatestRootRecord(store StateStoreReader) RootRecord
- func FetchLatestRootRecords(store StateStoreReader) []RootRecord
- func FetchRootRecord(store common.KVReader, branchTxID ledger.TransactionID) (ret RootRecord, found bool)
- func FetchRootRecords(store common.Traversable, slots ...ledger.Slot) []RootRecord
- func FetchRootRecordsNSlotsBack(store StateStoreReader, nBack int) []RootRecord
- func FindRootsFromLatestHealthySlot(store StateStoreReader, fraction global.Fraction) ([]RootRecord, bool)
- func RootRecordFromBytes(data []byte) (RootRecord, error)
- func (r *RootRecord) Bytes() []byte
- func (r *RootRecord) IsCoverageAboveThreshold(numerator, denominator int) bool
- func (r *RootRecord) JSONAble() *RootRecordJSONAble
- func (r *RootRecord) Lines(prefix ...string) *lines.Lines
- func (r *RootRecord) LinesVerbose(prefix ...string) *lines.Lines
- func (r *RootRecord) StringShort() string
- type RootRecordJSONAble
- type RootRecordParams
- type SequencerInfo
- type SnapshotFileStream
- type SnapshotHeader
- type SnapshotStats
- type StateIndexReader
- type StateReader
- type StateStore
- type StateStoreReader
- type SugaredStateReader
- func MakeSugared(s IndexedStateReader) SugaredStateReader
- func MustNewSugaredReadableState(store common.KVReader, root common.VCommitment, clearCacheAsSize ...int) SugaredStateReader
- func NewSugaredReadableState(store common.KVReader, root common.VCommitment, clearCacheAsSize ...int) (SugaredStateReader, error)
- func (s SugaredStateReader) BalanceOf(addr ledger.AccountID) uint64
- func (s SugaredStateReader) BalanceOnChain(chainID *ledger.ChainID) uint64
- func (s SugaredStateReader) GetAllChains() (map[ledger.ChainID]ChainRecordInfo, error)
- func (s SugaredStateReader) GetChainOutput(chainID *ledger.ChainID) (*ledger.OutputWithID, error)
- func (s SugaredStateReader) GetChainTips(chainID *ledger.ChainID) (*ledger.OutputWithID, *ledger.OutputWithID, error)
- func (s SugaredStateReader) GetOutput(oid *ledger.OutputID) *ledger.Output
- func (s SugaredStateReader) GetOutputErr(oid *ledger.OutputID) (*ledger.Output, error)
- func (s SugaredStateReader) GetOutputWithID(oid *ledger.OutputID) (*ledger.OutputWithID, error)
- func (s SugaredStateReader) GetOutputsDelegatedToAccount(addr ledger.Accountable) ([]*ledger.OutputWithChainID, error)
- func (s SugaredStateReader) GetOutputsForAccount(addr ledger.AccountID) ([]*ledger.OutputWithID, error)
- func (s SugaredStateReader) GetOutputsLockedInAddressED25519ForAmount(addr ledger.AddressED25519, targetAmount uint64) ([]*ledger.OutputWithID, uint64)
- func (s SugaredStateReader) GetStemOutput() *ledger.OutputWithID
- func (s SugaredStateReader) IterateChainsInAccount(addr ledger.Accountable, ...) error
- func (s SugaredStateReader) IterateDelegatedOutputs(delegationTarget ledger.Accountable, ...)
- func (s SugaredStateReader) IterateOutputsForAccount(addr ledger.Accountable, fun func(oid ledger.OutputID, o *ledger.Output) bool) (err error)
- func (s SugaredStateReader) MustGetOutputWithID(oid *ledger.OutputID) *ledger.OutputWithID
- func (s SugaredStateReader) NumOutputs(addr ledger.AccountID) int
- type SummarySupplyAndInflation
- type Updatable
Constants ¶
const ( TriePartitionLedgerState = byte(iota) TriePartitionAccounts TriePartitionChainID TriePartitionCommittedTransactionID )
partitions of the state store on the trie
const (
TmpSnapshotFileNamePrefix = "__tmp__"
)
Variables ¶
var ErrNotFound = errors.New("object not found")
Functions ¶
func BalanceOnChainOutput ¶
func BalanceOnChainOutput(rdr StateIndexReader, chainID *ledger.ChainID) uint64
func BalanceOnLock ¶
func BalanceOnLock(rdr StateIndexReader, account ledger.Accountable) (uint64, int)
BalanceOnLock returns balance and number of outputs
func BranchKnowsTransaction ¶
func BranchKnowsTransaction(branchID, txid *ledger.TransactionID, getStore func() common.KVReader) bool
BranchKnowsTransaction returns true if predecessor txid is known in the descendents state
func CommitEmptyRootWithLedgerIdentity ¶
func CommitEmptyRootWithLedgerIdentity(par ledger.IdentityData, store StateStore) (common.VCommitment, error)
CommitEmptyRootWithLedgerIdentity writes ledger identity data as value of the empty key nil. Return root of the empty trie
func FetchEarliestSlot ¶
FetchEarliestSlot return earliest slot among roots in the multi-state DB. It is set when multi-state DB is initialized and then remains immutable. For genesis database it is 0, For DB created from snapshot it is slot of the snapshot
func FetchLatestBranchTransactionIDs ¶
func FetchLatestBranchTransactionIDs(store StateStoreReader) []ledger.TransactionID
FetchLatestBranchTransactionIDs sorted descending by coverage
func FetchLatestCommittedSlot ¶
FetchLatestCommittedSlot fetches latest recorded slot
func FetchSnapshotBranchID ¶
func FetchSnapshotBranchID(store common.KVTraversableReader) ledger.TransactionID
func FindLatestHealthySlot ¶
FindLatestHealthySlot finds latest slot, which has at least one branch with coverage > numerator/denominator * 2 * totalSupply Returns false flag if not found
func FirstHealthySlotIsNotBefore ¶
func FirstHealthySlotIsNotBefore(store StateStoreReader, refSlot ledger.Slot, fraction global.Fraction) (ret bool)
FirstHealthySlotIsNotBefore determines if first healthy slot is nor before tha refSlot. Usually refSlot is just few slots back, so the operation does not require each time traversing unbounded number of slots
func InitLedgerFromStore ¶
func InitLedgerFromStore(stateStore StateStore, verbose ...bool)
func InitStateStore ¶
func InitStateStore(par ledger.IdentityData, store StateStore) (ledger.ChainID, common.VCommitment)
InitStateStore initializes origin ledger state in the empty store Writes initial supply and origin stem outputs. Plus writes root record into the DB Returns root commitment to the genesis ledger state and genesis chainID
func IterateBranchChainBack ¶
func IterateBranchChainBack(store StateStoreReader, branch *BranchData, fun func(branchID *ledger.TransactionID, branch *BranchData) bool)
IterateBranchChainBack iterates past chain of the tip branch (including the tip) Stops when current branch have no predecessor
func IterateRootRecords ¶
func IterateRootRecords(store common.Traversable, fun func(branchTxID ledger.TransactionID, rootData RootRecord) bool, optSlot ...ledger.Slot)
IterateRootRecords iterates root records in the store: - if len(optSlot) > 0, it iterates specific slots - if len(optSlot) == 0, it iterates all records in the store
func IterateSlotsBack ¶
func IterateSlotsBack(store StateStoreReader, fun func(slot ledger.Slot, roots []RootRecord) bool)
IterateSlotsBack iterates descending slots from latest committed slot down to the earliest available
func LedgerIdentityBytesFromRoot ¶
func LedgerIdentityBytesFromRoot(store StateStoreReader, root common.VCommitment) []byte
func LedgerIdentityBytesFromStore ¶
func LedgerIdentityBytesFromStore(store StateStore) []byte
func PartitionToString ¶
func RootHasTransaction ¶
func RootHasTransaction(store common.KVReader, root common.VCommitment, txid *ledger.TransactionID) bool
func SaveBranchTree ¶
func SaveBranchTree(stateStore StateStore, fname string, slotsBack ...int)
func ScanGenesisState ¶
func ScanGenesisState(stateStore StateStore) (*ledger.IdentityData, common.VCommitment, error)
ScanGenesisState TODO more checks
func UpdateTrie ¶
func UpdateTrie(trie *immutable.TrieUpdatable, mut *Mutations) (err error)
func WriteRootRecord ¶
func WriteRootRecord(w common.KVWriter, branchTxID ledger.TransactionID, rootData RootRecord)
Types ¶
type AccountInfo ¶
type AccountInfo struct { LockedAccounts map[string]LockedAccountInfo ChainRecords map[ledger.ChainID]ChainRecordInfo }
func MustCollectAccountInfo ¶
func MustCollectAccountInfo(store StateStore, root common.VCommitment) *AccountInfo
type BranchData ¶
type BranchData struct { RootRecord Stem *ledger.OutputWithID SequencerOutput *ledger.OutputWithID }
func CheckTransactionInLRB ¶
func CheckTransactionInLRB(store StateStoreReader, txid ledger.TransactionID, maxDepth int, fraction global.Fraction) (lrb *BranchData, foundAtDepth int)
CheckTransactionInLRB return number of slots behind the LRB which contains txid. The backwards scan is capped by maxDepth parameter. If maxDepth == 0, it means only LRB is checked
func FetchBranchData ¶
func FetchBranchData(store common.KVReader, branchTxID ledger.TransactionID) (BranchData, bool)
FetchBranchData returns branch data by the branch transaction ID
func FetchBranchDataByRoot ¶
func FetchBranchDataByRoot(store common.KVReader, rootData RootRecord) BranchData
FetchBranchDataByRoot returns existing branch data by root record. The root record usually returned by FetchRootRecord
func FetchBranchDataMulti ¶
func FetchBranchDataMulti(store common.KVReader, rootData ...RootRecord) []*BranchData
FetchBranchDataMulti returns branch records for particular root records
func FetchHeaviestBranchChainNSlotsBack ¶
func FetchHeaviestBranchChainNSlotsBack(store StateStoreReader, nBack int) []*BranchData
FetchHeaviestBranchChainNSlotsBack descending by epoch
func FetchLatestBranches ¶
func FetchLatestBranches(store StateStoreReader) []*BranchData
FetchLatestBranches branches of the latest slot sorted by coverage descending
func FindFirstBranch ¶
func FindFirstBranch(store StateStoreReader, filter func(branch *BranchData) bool) *BranchData
func FindLatestReliableBranch ¶
func FindLatestReliableBranch(store StateStoreReader, fraction global.Fraction) *BranchData
FindLatestReliableBranch latest reliable branch (LRB) is the latest branch, which is contained in any tip from the latest healthy branch with ledger coverage bigger than fraction total supply. Reliable branch is the latest global consensus state with big probability Returns nil if not found
func FindLatestReliableBranchAndNSlotsBack ¶
func FindLatestReliableBranchAndNSlotsBack(store StateStoreReader, n int, fraction global.Fraction) (ret *BranchData)
FindLatestReliableBranchAndNSlotsBack finds LRB and iterates n slots back along the main chain from LRB. It is a precaution if LRB will be orphaned later
func FindLatestReliableBranchWithSequencerID ¶
func FindLatestReliableBranchWithSequencerID(store StateStoreReader, seqID ledger.ChainID, fraction global.Fraction) (ret *BranchData)
FindLatestReliableBranchWithSequencerID finds first branch with the given sequencerID in the main LRBID chain
func GetMainChain ¶
func GetMainChain(store StateStoreReader, fraction global.Fraction, max ...int) ([]*BranchData, error)
func (*BranchData) JSONAble ¶
func (br *BranchData) JSONAble() *BranchDataJSONAble
func (*BranchData) LinesVerbose ¶
func (br *BranchData) LinesVerbose(prefix ...string) *lines.Lines
func (*BranchData) TxID ¶
func (br *BranchData) TxID() *ledger.TransactionID
TxID transaction ID of the branch, as taken from the stem output ID
type BranchDataJSONAble ¶
type BranchDataJSONAble struct { Root RootRecordJSONAble `json:"root"` StemOutputIndex byte `json:"stem_output_index"` SequencerOutputIndex byte `json:"sequencer_output_index"` OnChainAmount uint64 `json:"on_chain_amount"` BranchInflation uint64 `json:"branch_inflation"` }
type ChainRecordInfo ¶
type ChainRecordInfo struct { Balance uint64 Output *ledger.OutputDataWithID }
type IndexedStateReader ¶
type IndexedStateReader interface { StateReader StateIndexReader }
IndexedStateReader state and indexer readers packing together
type LockedAccountInfo ¶
type Mutations ¶
type Mutations struct {
// contains filtered or unexported fields
}
func NewMutations ¶
func NewMutations() *Mutations
func (*Mutations) InsertAddOutputMutation ¶
func (*Mutations) InsertAddTxMutation ¶
func (*Mutations) InsertDelChainMutation ¶
func (*Mutations) InsertDelOutputMutation ¶
type Readable ¶
type Readable struct {
// contains filtered or unexported fields
}
Readable is a read-only ledger state, with the particular root It is thread-safe. The state itself is read-only, but trie cache needs write-lock with every call
func MustNewReadable ¶
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) AccountsByLocks ¶
func (r *Readable) AccountsByLocks() map[string]LockedAccountInfo
func (*Readable) GetUTXOForChainID ¶
func (*Readable) GetUTXOIDsInAccount ¶
func (*Readable) GetUTXOsInAccount ¶
func (*Readable) IterateChainTips ¶
func (*Readable) IterateKnownCommittedTransactions ¶
func (r *Readable) IterateKnownCommittedTransactions(fun func(txid *ledger.TransactionID, slot ledger.Slot) bool, txidSlot ...ledger.Slot)
IterateKnownCommittedTransactions iterates transaction IDs in the state. Optionally, iteration is restricted for a slot. In that case first iterates non-sequencer transactions, the sequencer transactions
func (*Readable) IterateUTXOIDsInAccount ¶
func (*Readable) IterateUTXOsInAccount ¶
func (*Readable) KnowsCommittedTransaction ¶
func (r *Readable) KnowsCommittedTransaction(txid *ledger.TransactionID) bool
KnowsCommittedTransaction transaction IDs are purged after some time, so the result may be
func (*Readable) MustLedgerIdentityBytes ¶
func (*Readable) Root ¶
func (r *Readable) Root() common.VCommitment
type RootRecord ¶
type RootRecord struct { Root common.VCommitment SequencerID ledger.ChainID // Note: LedgerCoverage, SlotInflation and Supply are deterministic values calculated from the ledger past cone // Each node calculates them itself, and they must be equal on each LedgerCoverage uint64 // SlotInflation: total inflation delta from previous root. It is a sum of individual transaction inflation values // of the previous slot/past cone. It includes the branch tx inflation itself and does not include inflation of the previous branch SlotInflation uint64 // Supply: total supply at this root (including the branch itself, excluding prev branch). // It is the sum of the Supply of the previous branch and SlotInflation of the current Supply uint64 // Number of new transactions in the slot of the branch NumTransactions uint32 }
RootRecord is a persistent data stored in the DB partition with each state root It contains deterministic values for that state
func FetchAllRootRecords ¶
func FetchAllRootRecords(store common.Traversable) []RootRecord
FetchAllRootRecords returns all root records in the DB
func FetchAnyLatestRootRecord ¶
func FetchAnyLatestRootRecord(store StateStoreReader) RootRecord
FetchAnyLatestRootRecord return first root record for the latest slot
func FetchLatestRootRecords ¶
func FetchLatestRootRecords(store StateStoreReader) []RootRecord
FetchLatestRootRecords sorted descending by coverage
func FetchRootRecord ¶
func FetchRootRecord(store common.KVReader, branchTxID ledger.TransactionID) (ret RootRecord, found bool)
FetchRootRecord returns root data, stem output index and existence flag Exactly one root record must exist for the branch transaction
func FetchRootRecords ¶
func FetchRootRecords(store common.Traversable, slots ...ledger.Slot) []RootRecord
FetchRootRecords returns root records for particular slots in the DB
func FetchRootRecordsNSlotsBack ¶
func FetchRootRecordsNSlotsBack(store StateStoreReader, nBack int) []RootRecord
FetchRootRecordsNSlotsBack load root records from N lates slots, present in the store
func FindRootsFromLatestHealthySlot ¶
func FindRootsFromLatestHealthySlot(store StateStoreReader, fraction global.Fraction) ([]RootRecord, bool)
FindRootsFromLatestHealthySlot Healthy slot is a slot which contains at least one healthy root. Function returns all roots from the latest healthy slot. Note that in theory latest healthy slot it may not exist at all, i.e. all slot in the DB does not contain any healthy root. Normally it will exist tho, because: - either database contains all branches down to genesis - or it was started from snapshot which (normally) represents a healthy state
func RootRecordFromBytes ¶
func RootRecordFromBytes(data []byte) (RootRecord, error)
func (*RootRecord) Bytes ¶
func (r *RootRecord) Bytes() []byte
func (*RootRecord) IsCoverageAboveThreshold ¶
func (r *RootRecord) IsCoverageAboveThreshold(numerator, denominator int) bool
IsCoverageAboveThreshold the root is dominating if coverage last delta is more than numerator/denominator of the double supply
func (*RootRecord) JSONAble ¶
func (r *RootRecord) JSONAble() *RootRecordJSONAble
func (*RootRecord) LinesVerbose ¶
func (r *RootRecord) LinesVerbose(prefix ...string) *lines.Lines
func (*RootRecord) StringShort ¶
func (r *RootRecord) StringShort() string
type RootRecordJSONAble ¶
type RootRecordJSONAble struct { Root string `json:"root"` SequencerID string `json:"sequencer_id"` LedgerCoverage uint64 `json:"ledger_coverage"` SlotInflation uint64 `json:"slot_inflation"` Supply uint64 `json:"supply"` }
func (*RootRecordJSONAble) Parse ¶
func (r *RootRecordJSONAble) Parse() (*RootRecord, error)
type RootRecordParams ¶
type SequencerInfo ¶
type SnapshotFileStream ¶
type SnapshotFileStream struct { Header *SnapshotHeader LedgerID *ledger.IdentityData BranchID ledger.TransactionID RootRecord RootRecord InChan chan common.KVPairOrError Close func() }
func OpenSnapshotFileStream ¶
func OpenSnapshotFileStream(fname string) (*SnapshotFileStream, error)
OpenSnapshotFileStream reads first 3 records in the snapshot file and returns channel for remaining key/value pairs
type SnapshotHeader ¶
type SnapshotStats ¶
func SaveSnapshot ¶
func SaveSnapshot(state StateStoreReader, branch *BranchData, ctx context.Context, dir string, out ...io.Writer) (string, *SnapshotStats, error)
SaveSnapshot writes latest reliable state into snapshot. Returns snapshot file name
type StateIndexReader ¶
type StateIndexReader interface { IterateUTXOIDsInAccount(addr ledger.AccountID, fun func(oid ledger.OutputID) bool) (err error) IterateUTXOsInAccount(addr ledger.AccountID, fun func(oid ledger.OutputID, odata []byte) bool) (err error) IterateChainTips(fun func(chainID ledger.ChainID, oid ledger.OutputID) bool) error GetUTXOIDsInAccount(addr ledger.AccountID) ([]ledger.OutputID, error) GetUTXOsInAccount(accountID ledger.AccountID) ([]*ledger.OutputDataWithID, error) // TODO leave Iterate.. only? GetUTXOForChainID(id *ledger.ChainID) (*ledger.OutputDataWithID, error) Root() common.VCommitment MustLedgerIdentityBytes() []byte // either state identity consistent or panic }
type StateReader ¶
type StateStore ¶
type StateStore interface { StateStoreReader common.BatchedUpdatable }
type StateStoreReader ¶
type StateStoreReader interface { common.KVReader common.Traversable IsClosed() bool }
type SugaredStateReader ¶
type SugaredStateReader struct {
IndexedStateReader
}
func MakeSugared ¶
func MakeSugared(s IndexedStateReader) SugaredStateReader
func MustNewSugaredReadableState ¶
func MustNewSugaredReadableState(store common.KVReader, root common.VCommitment, clearCacheAsSize ...int) SugaredStateReader
func NewSugaredReadableState ¶
func NewSugaredReadableState(store common.KVReader, root common.VCommitment, clearCacheAsSize ...int) (SugaredStateReader, error)
func (SugaredStateReader) BalanceOf ¶
func (s SugaredStateReader) BalanceOf(addr ledger.AccountID) uint64
func (SugaredStateReader) BalanceOnChain ¶
func (s SugaredStateReader) BalanceOnChain(chainID *ledger.ChainID) uint64
func (SugaredStateReader) GetAllChains ¶
func (s SugaredStateReader) GetAllChains() (map[ledger.ChainID]ChainRecordInfo, error)
func (SugaredStateReader) GetChainOutput ¶
func (s SugaredStateReader) GetChainOutput(chainID *ledger.ChainID) (*ledger.OutputWithID, error)
func (SugaredStateReader) GetChainTips ¶
func (s SugaredStateReader) GetChainTips(chainID *ledger.ChainID) (*ledger.OutputWithID, *ledger.OutputWithID, error)
GetChainTips return chain output and, if relevant, stem output for the chain ID. The stem output is nil if sequencer output is not in the branch
func (SugaredStateReader) GetOutput ¶
func (s SugaredStateReader) GetOutput(oid *ledger.OutputID) *ledger.Output
func (SugaredStateReader) GetOutputErr ¶
func (SugaredStateReader) GetOutputWithID ¶
func (s SugaredStateReader) GetOutputWithID(oid *ledger.OutputID) (*ledger.OutputWithID, error)
func (SugaredStateReader) GetOutputsDelegatedToAccount ¶
func (s SugaredStateReader) GetOutputsDelegatedToAccount(addr ledger.Accountable) ([]*ledger.OutputWithChainID, error)
func (SugaredStateReader) GetOutputsForAccount ¶
func (s SugaredStateReader) GetOutputsForAccount(addr ledger.AccountID) ([]*ledger.OutputWithID, error)
func (SugaredStateReader) GetOutputsLockedInAddressED25519ForAmount ¶
func (s SugaredStateReader) GetOutputsLockedInAddressED25519ForAmount(addr ledger.AddressED25519, targetAmount uint64) ([]*ledger.OutputWithID, uint64)
GetOutputsLockedInAddressED25519ForAmount returns outputs locked in simple address. Skip delegated and other
func (SugaredStateReader) GetStemOutput ¶
func (s SugaredStateReader) GetStemOutput() *ledger.OutputWithID
func (SugaredStateReader) IterateChainsInAccount ¶
func (SugaredStateReader) IterateDelegatedOutputs ¶
func (s SugaredStateReader) IterateDelegatedOutputs(delegationTarget ledger.Accountable, fun func(oid ledger.OutputID, o *ledger.Output, dLock *ledger.DelegationLock) bool)
func (SugaredStateReader) IterateOutputsForAccount ¶
func (s SugaredStateReader) IterateOutputsForAccount(addr ledger.Accountable, fun func(oid ledger.OutputID, o *ledger.Output) bool) (err error)
func (SugaredStateReader) MustGetOutputWithID ¶
func (s SugaredStateReader) MustGetOutputWithID(oid *ledger.OutputID) *ledger.OutputWithID
func (SugaredStateReader) NumOutputs ¶
func (s SugaredStateReader) NumOutputs(addr ledger.AccountID) int
type SummarySupplyAndInflation ¶
type SummarySupplyAndInflation struct { NumberOfBranches int OldestSlot ledger.Slot LatestSlot ledger.Slot BeginSupply uint64 EndSupply uint64 TotalInflation uint64 InfoPerSeqID map[ledger.ChainID]SequencerInfo }
func FetchSummarySupply ¶
func FetchSummarySupply(stateStore StateStore, nBack int) *SummarySupplyAndInflation
type Updatable ¶
type Updatable struct {
// contains filtered or unexported fields
}
Updatable is an updatable ledger state, with the particular root Suitable for chained updates Not-thread safe, should be used individual instance for each parallel update. DB (store) is updated atomically with all mutations in one DB transaction
func MustNewUpdatable ¶
func MustNewUpdatable(store StateStore, root common.VCommitment) *Updatable
func NewUpdatable ¶
func NewUpdatable(store 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) MustUpdate ¶
func (u *Updatable) MustUpdate(muts *Mutations, par *RootRecordParams)
func (*Updatable) Root ¶
func (u *Updatable) Root() common.VCommitment