store

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AccountPrefix        = []byte{0x00}
	NanoPayPrefix        = []byte{0x01}
	NanoPayCleanupPrefix = []byte{0x02}
	NamePrefix_legacy    = []byte{0x03}
	NameRegistrantPrefix = []byte{0x04}
	PubSubPrefix         = []byte{0x05}
	PubSubCleanupPrefix  = []byte{0x06}
	IssueAssetPrefix     = []byte{0x07}
	NamePrefix           = []byte{0x08}
	NameCleanupPrefix    = []byte{0x09}
)

Functions

func NewAccount

func NewAccount(n uint64, b *balance, id []byte) *account

func NewTrieStore

func NewTrieStore(db db.IStore) *cachingDB

Types

type Asset

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

func (*Asset) Deserialize

func (ia *Asset) Deserialize(r io.Reader) error

func (*Asset) Empty

func (ia *Asset) Empty() bool

func (*Asset) Serialize

func (ia *Asset) Serialize(w io.Writer) error

type ChainStore

type ChainStore struct {
	States *StateDB
	// contains filtered or unexported fields
}

func NewLedgerStore

func NewLedgerStore() (*ChainStore, error)

func (*ChainStore) AddHeader

func (cs *ChainStore) AddHeader(header *block.Header) error

func (*ChainStore) CalcNextDonation_legacy

func (cs *ChainStore) CalcNextDonation_legacy(height uint32) (*Donation, error)

func (*ChainStore) Close

func (cs *ChainStore) Close()

func (*ChainStore) FastSyncDone

func (cs *ChainStore) FastSyncDone(syncRootHash common.Uint256, fastSyncHeight uint32) error

func (*ChainStore) GenerateStateRoot

func (cs *ChainStore) GenerateStateRoot(ctx context.Context, b *block.Block, genesisBlockInitialized, needBeCommitted bool) (common.Uint256, error)

func (*ChainStore) GetAsset

func (cs *ChainStore) GetAsset(assetID common.Uint256) (name, symbol string, totalSupply common.Fixed64, precision uint32, err error)

func (*ChainStore) GetBalance

func (cs *ChainStore) GetBalance(addr common.Uint160) common.Fixed64

func (*ChainStore) GetBalanceByAssetID

func (cs *ChainStore) GetBalanceByAssetID(addr common.Uint160, assetID common.Uint256) common.Fixed64

func (*ChainStore) GetBlock

func (cs *ChainStore) GetBlock(hash common.Uint256) (*block.Block, error)

func (*ChainStore) GetBlockByHeight

func (cs *ChainStore) GetBlockByHeight(height uint32) (*block.Block, error)

func (*ChainStore) GetBlockHash

func (cs *ChainStore) GetBlockHash(height uint32) (common.Uint256, error)

func (*ChainStore) GetCurrentBlockHash

func (cs *ChainStore) GetCurrentBlockHash() common.Uint256

func (*ChainStore) GetCurrentBlockHashFromDB

func (cs *ChainStore) GetCurrentBlockHashFromDB() (common.Uint256, uint32, error)

func (*ChainStore) GetCurrentBlockStateRoot

func (cs *ChainStore) GetCurrentBlockStateRoot() (common.Uint256, error)

func (*ChainStore) GetCurrentHeaderHash

func (cs *ChainStore) GetCurrentHeaderHash() common.Uint256

func (*ChainStore) GetDatabase

func (cs *ChainStore) GetDatabase() db.IStore

func (*ChainStore) GetDonation

func (cs *ChainStore) GetDonation() (common.Fixed64, error)

func (*ChainStore) GetFastSyncStateRoot

func (cs *ChainStore) GetFastSyncStateRoot() (common.Uint256, error)

func (*ChainStore) GetHeader

func (cs *ChainStore) GetHeader(hash common.Uint256) (*block.Header, error)

func (*ChainStore) GetHeaderByHeight

func (cs *ChainStore) GetHeaderByHeight(height uint32) (*block.Header, error)

func (*ChainStore) GetHeaderHashByHeight

func (cs *ChainStore) GetHeaderHashByHeight(height uint32) common.Uint256

func (*ChainStore) GetHeaderHeight

func (cs *ChainStore) GetHeaderHeight() uint32

func (*ChainStore) GetHeaderWithCache

func (cs *ChainStore) GetHeaderWithCache(hash common.Uint256) (*block.Header, error)

func (*ChainStore) GetHeight

func (cs *ChainStore) GetHeight() uint32

func (*ChainStore) GetHeightByBlockHash

func (cs *ChainStore) GetHeightByBlockHash(hash common.Uint256) (uint32, error)

func (*ChainStore) GetID

func (cs *ChainStore) GetID(publicKey []byte, height uint32) ([]byte, error)

func (*ChainStore) GetIDVersion

func (cs *ChainStore) GetIDVersion(publicKey []byte) ([]byte, byte, error)

func (*ChainStore) GetName_legacy

func (cs *ChainStore) GetName_legacy(registrant []byte) (string, error)

func (*ChainStore) GetNanoPay

func (cs *ChainStore) GetNanoPay(addr common.Uint160, recipient common.Uint160, nonce uint64) (common.Fixed64, uint32, error)

func (*ChainStore) GetNonce

func (cs *ChainStore) GetNonce(addr common.Uint160) uint64

func (*ChainStore) GetPruningStartHeight

func (cs *ChainStore) GetPruningStartHeight() (uint32, uint32)

func (*ChainStore) GetRDCBalance

func (cs *ChainStore) GetRDCBalance(addr common.Uint160) common.Fixed64

func (*ChainStore) GetRegistrant

func (cs *ChainStore) GetRegistrant(name string) ([]byte, uint32, error)

func (*ChainStore) GetRegistrant_legacy

func (cs *ChainStore) GetRegistrant_legacy(name string) ([]byte, error)

func (*ChainStore) GetSigChainWithCache

func (cs *ChainStore) GetSigChainWithCache(hash common.Uint256) (*pb.SigChain, error)

func (*ChainStore) GetStateRoots

func (cs *ChainStore) GetStateRoots(fromHeight, toHeight uint32) ([]common.Uint256, error)

func (*ChainStore) GetSubscribers

func (cs *ChainStore) GetSubscribers(topic string, bucket, offset, limit uint32, subscriberHashPrefix []byte, ctx context.Context) ([]string, error)

func (*ChainStore) GetSubscribersCount

func (cs *ChainStore) GetSubscribersCount(topic string, bucket uint32, subscriberHashPrefix []byte, ctx context.Context) (int, error)

func (*ChainStore) GetSubscribersWithMeta

func (cs *ChainStore) GetSubscribersWithMeta(topic string, bucket, offset, limit uint32, subscriberHashPrefix []byte, ctx context.Context) (map[string]string, error)

func (*ChainStore) GetSubscription

func (cs *ChainStore) GetSubscription(topic string, bucket uint32, subscriber []byte, identifier string) (string, uint32, error)

func (*ChainStore) GetSyncRootHeight

func (cs *ChainStore) GetSyncRootHeight() (uint32, error)

func (*ChainStore) GetTransaction

func (cs *ChainStore) GetTransaction(hash common.Uint256) (*transaction.Transaction, error)

func (*ChainStore) InitLedgerStoreWithGenesisBlock

func (cs *ChainStore) InitLedgerStoreWithGenesisBlock(genesisBlock *block.Block) (uint32, error)

func (*ChainStore) IsBlockInStore

func (cs *ChainStore) IsBlockInStore(hash common.Uint256) bool

func (*ChainStore) IsDoubleSpend

func (cs *ChainStore) IsDoubleSpend(tx *transaction.Transaction) bool

func (*ChainStore) IsSubscribed

func (cs *ChainStore) IsSubscribed(topic string, bucket uint32, subscriber []byte, identifier string) (bool, error)

func (*ChainStore) IsTxHashDuplicate

func (cs *ChainStore) IsTxHashDuplicate(txhash common.Uint256) bool

func (*ChainStore) PrepareFastSync

func (cs *ChainStore) PrepareFastSync(fastSyncHeight uint32, fastSyncRootHash common.Uint256) error

func (*ChainStore) PruneStates

func (cs *ChainStore) PruneStates() error

PruneStates is not in use due to high memory usage. Use PruneStatesLowMemory instead.

func (*ChainStore) PruneStatesLowMemory

func (cs *ChainStore) PruneStatesLowMemory(full bool) error

func (*ChainStore) ResetDB

func (cs *ChainStore) ResetDB() error

func (*ChainStore) Rollback

func (cs *ChainStore) Rollback(b *block.Block) error

func (*ChainStore) SaveBlock

func (cs *ChainStore) SaveBlock(b *block.Block, pruning, fastSync bool) error

func (*ChainStore) SequentialPrune

func (cs *ChainStore) SequentialPrune() error

SequentialPrune is not in use due to high memory usage. Use PruneStatesLowMemory instead.

func (*ChainStore) ShouldFastSync

func (cs *ChainStore) ShouldFastSync(syncStopHeight uint32) bool

func (*ChainStore) TrieTraverse

func (cs *ChainStore) TrieTraverse(needPrint bool) error

func (*ChainStore) VerifyState

func (cs *ChainStore) VerifyState() error

type Donation

type Donation struct {
	Height uint32
	Amount common.Fixed64
}

func NewDonation

func NewDonation(height uint32, amount common.Fixed64) *Donation

func (*Donation) Deserialize

func (d *Donation) Deserialize(r io.Reader) error

func (*Donation) Serialize

func (d *Donation) Serialize(w io.Writer) error

type HeaderCache

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

func NewHeaderCache

func NewHeaderCache() *HeaderCache

func (*HeaderCache) AddHeaderToCache

func (hc *HeaderCache) AddHeaderToCache(header *block.Header)

func (*HeaderCache) Dump

func (hc *HeaderCache) Dump()

func (*HeaderCache) GetCachedHeader

func (hc *HeaderCache) GetCachedHeader(hash common.Uint256) (*block.Header, error)

func (*HeaderCache) GetCachedHeaderHashByHeight

func (hc *HeaderCache) GetCachedHeaderHashByHeight(height uint32) common.Uint256

func (*HeaderCache) GetCurrentCacheHeaderHash

func (hc *HeaderCache) GetCurrentCacheHeaderHash() common.Uint256

func (*HeaderCache) GetCurrentCachedHeight

func (hc *HeaderCache) GetCurrentCachedHeight() uint32

func (*HeaderCache) RemoveCachedHeader

func (hc *HeaderCache) RemoveCachedHeader(height uint32)

func (*HeaderCache) RollbackHeader

func (hc *HeaderCache) RollbackHeader(h *block.Header)

type ITrie

type ITrie interface {
	TryGet(key []byte) ([]byte, error)
	TryUpdate(key, value []byte) error
	TryDelete(key []byte) error
	TryTraverse(needPrint bool) error
	Hash() common.Uint256
	CommitTo() (common.Uint256, error)
	NodeIterator(start []byte) trie.NodeIterator
	NewRefCounts(refCountTargetHeight, pruningTargetHeight uint32) (*trie.RefCounts, error)
}

type Operation

type Operation int
const (
	Addition Operation = iota
	Subtraction
)

type SigChainCache

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

func NewSigChainCache

func NewSigChainCache() *SigChainCache

func (*SigChainCache) AddSigChainToCache

func (s *SigChainCache) AddSigChainToCache(hash common.Uint256, sc *pb.SigChain)

func (*SigChainCache) GetCachedSigChain

func (s *SigChainCache) GetCachedSigChain(hash common.Uint256) (*pb.SigChain, error)

func (*SigChainCache) RemoveCachedSigChain

func (s *SigChainCache) RemoveCachedSigChain(h []byte)

func (*SigChainCache) RollbackSigChain

func (s *SigChainCache) RollbackSigChain(h *block.Header)

type StateDB

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

func NewStateDB

func NewStateDB(root common.Uint256, cs *ChainStore) (*StateDB, error)

func (*StateDB) CleanupNames

func (sdb *StateDB) CleanupNames(height uint32) error

func (*StateDB) CleanupNanoPay

func (sdb *StateDB) CleanupNanoPay(height uint32) error

func (*StateDB) CleanupPubSub

func (sdb *StateDB) CleanupPubSub(height uint32) error

func (*StateDB) Finalize

func (sdb *StateDB) Finalize(commit bool) (common.Uint256, error)

func (*StateDB) FinalizeAccounts

func (sdb *StateDB) FinalizeAccounts(commit bool) error

func (*StateDB) FinalizeIssueAsset

func (sdb *StateDB) FinalizeIssueAsset(commit bool) error

func (*StateDB) FinalizeNames

func (sdb *StateDB) FinalizeNames(commit bool) error

func (*StateDB) FinalizeNames_legacy

func (sdb *StateDB) FinalizeNames_legacy(commit bool) error

func (*StateDB) FinalizeNanoPay

func (sdb *StateDB) FinalizeNanoPay(commit bool) error

func (*StateDB) FinalizePubSub

func (sdb *StateDB) FinalizePubSub(commit bool) error

func (*StateDB) GetAsset

func (sdb *StateDB) GetAsset(assetID common.Uint256) (*Asset, error)

func (*StateDB) GetBalance

func (sdb *StateDB) GetBalance(assetID common.Uint256, addr common.Uint160) common.Fixed64

func (*StateDB) GetID

func (sdb *StateDB) GetID(addr common.Uint160, height uint32) []byte

func (*StateDB) GetIDVersion

func (sdb *StateDB) GetIDVersion(addr common.Uint160) ([]byte, byte)

func (*StateDB) GetNanoPay

func (sdb *StateDB) GetNanoPay(sender, recipient common.Uint160, nonce uint64) (common.Fixed64, uint32, error)

func (*StateDB) GetNonce

func (sdb *StateDB) GetNonce(addr common.Uint160) uint64

func (*StateDB) GetOrNewAccount

func (sdb *StateDB) GetOrNewAccount(addr common.Uint160) *account

func (*StateDB) GetState

func (sdb *StateDB) GetState(hash common.Uint256) ([]byte, error)

GetState retrieves an encoded cached trie node from memory. If it cannot be found cached, the method queries the persistent database for the content.

func (*StateDB) IncrNonce

func (sdb *StateDB) IncrNonce(addr common.Uint160) error

func (*StateDB) IntermediateRoot

func (sdb *StateDB) IntermediateRoot() (common.Uint256, error)

func (*StateDB) NewBatch

func (sdb *StateDB) NewBatch() error

func (*StateDB) PruneStates

func (sdb *StateDB) PruneStates() error

PruneStates is not in use due to high memory usage. Use PruneStatesLowMemory instead.

func (*StateDB) PruneStatesLowMemory

func (sdb *StateDB) PruneStatesLowMemory(full bool) error

func (*StateDB) RollbackPruning

func (sdb *StateDB) RollbackPruning(b *block.Block) error

func (*StateDB) SequentialPrune

func (sdb *StateDB) SequentialPrune() error

SequentialPrune is not in use due to high memory usage. Use PruneStatesLowMemory instead.

func (*StateDB) SetAccount

func (sdb *StateDB) SetAccount(addr common.Uint160, acc *account)

func (*StateDB) SetAsset

func (sdb *StateDB) SetAsset(assetID common.Uint256, name string, symbol string, totalSupply common.Fixed64, precision uint32, owner common.Uint160) error

func (*StateDB) SetBalance

func (sdb *StateDB) SetBalance(addr common.Uint160, assetID common.Uint256, value common.Fixed64) error

func (*StateDB) SetID

func (sdb *StateDB) SetID(addr common.Uint160, id []byte, version byte) error

func (*StateDB) SetNanoPay

func (sdb *StateDB) SetNanoPay(sender, recipient common.Uint160, nonce uint64, balance common.Fixed64, expiresAt uint32) error

func (*StateDB) SetNonce

func (sdb *StateDB) SetNonce(addr common.Uint160, nonce uint64) error

func (*StateDB) TrieTraverse

func (sdb *StateDB) TrieTraverse(needPrint bool) error

func (*StateDB) UpdateBalance

func (sdb *StateDB) UpdateBalance(addr common.Uint160, assetID common.Uint256, value common.Fixed64, op Operation) error

func (*StateDB) UpdateID

func (sdb *StateDB) UpdateID(addr common.Uint160, id []byte, version byte) error

func (*StateDB) VerifyState

func (sdb *StateDB) VerifyState() error

Jump to

Keyboard shortcuts

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