state

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: LGPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Copyright 2020 ChainSafe Systems (ON) Corp. This file is part of gossamer.

The gossamer library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The gossamer library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the gossamer library. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

View Source
var ErrTrieDoesNotExist = errors.New("trie with given root does not exist")

ErrTrieDoesNotExist is returned when attempting to interact with a trie that is not stored in the StorageState

Functions

func AddBlocksToState

func AddBlocksToState(t *testing.T, blockState *BlockState, depth int) ([]*types.Header, []*types.Header)

AddBlocksToState adds blocks to a BlockState up to depth, with random branches

func AddBlocksToStateWithFixedBranches

func AddBlocksToStateWithFixedBranches(t *testing.T, blockState *BlockState, depth int, branches map[int]int, r byte)

AddBlocksToStateWithFixedBranches adds blocks to a BlockState up to depth, with fixed branches branches are provided with a map of depth -> # of branches

func LoadBestBlockHash

func LoadBestBlockHash(db database.Database) (common.Hash, error)

LoadBestBlockHash loads the hash stored at BestBlockHashKey

func LoadGenesisData

func LoadGenesisData(db database.Database) (*genesis.Data, error)

LoadGenesisData retrieves the genesis data stored at the known GenesisDataKey.

func LoadLatestStorageHash

func LoadLatestStorageHash(db database.Database) (common.Hash, error)

LoadLatestStorageHash retrieves the hash stored at LatestStorageHashKey from the DB

func LoadTrie

func LoadTrie(db database.Database, t *trie.Trie, root common.Hash) error

LoadTrie loads an encoded trie from the DB where the key is `root`

func StoreBestBlockHash

func StoreBestBlockHash(db database.Database, hash common.Hash) error

StoreBestBlockHash stores the hash at the BestBlockHashKey

func StoreGenesisData

func StoreGenesisData(db database.Database, gen *genesis.Data) error

StoreGenesisData stores the given genesis data at the known GenesisDataKey.

func StoreLatestStorageHash

func StoreLatestStorageHash(db database.Database, t *trie.Trie) error

StoreLatestStorageHash stores the current root hash in the database at LatestStorageHashKey

func StoreTrie

func StoreTrie(db database.Database, t *trie.Trie) error

StoreTrie encodes the entire trie and writes it to the DB The key to the DB entry is the root hash of the trie

Types

type BlockState

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

BlockState defines fields for manipulating the state of blocks, such as BlockTree, BlockDB and Header

func NewBlockState

func NewBlockState(db chaindb.Database, bt *blocktree.BlockTree) (*BlockState, error)

NewBlockState will create a new BlockState backed by the database located at basePath

func NewBlockStateFromGenesis

func NewBlockStateFromGenesis(db chaindb.Database, header *types.Header) (*BlockState, error)

NewBlockStateFromGenesis initializes a BlockState from a genesis header, saving it to the database located at basePath

func (*BlockState) AddBlock

func (bs *BlockState) AddBlock(block *types.Block) error

AddBlock adds a block to the blocktree and the DB with arrival time as current unix time

func (*BlockState) AddBlockWithArrivalTime

func (bs *BlockState) AddBlockWithArrivalTime(block *types.Block, arrivalTime uint64) error

AddBlockWithArrivalTime adds a block to the blocktree and the DB with the given arrival time

func (*BlockState) BestBlock

func (bs *BlockState) BestBlock() (*types.Block, error)

BestBlock returns the current head of the chain

func (*BlockState) BestBlockHash

func (bs *BlockState) BestBlockHash() common.Hash

BestBlockHash returns the hash of the head of the current chain

func (*BlockState) BestBlockHeader

func (bs *BlockState) BestBlockHeader() (*types.Header, error)

BestBlockHeader returns the block header of the current head of the chain

func (*BlockState) BestBlockNumber

func (bs *BlockState) BestBlockNumber() (*big.Int, error)

BestBlockNumber returns the block number of the current head of the chain

func (*BlockState) BestBlockStateRoot added in v0.2.0

func (bs *BlockState) BestBlockStateRoot() (common.Hash, error)

BestBlockStateRoot returns the state root of the current head of the chain

func (*BlockState) BlocktreeAsString

func (bs *BlockState) BlocktreeAsString() string

BlocktreeAsString returns the blocktree as a string

func (*BlockState) CompareAndSetBlockData

func (bs *BlockState) CompareAndSetBlockData(bd *types.BlockData) error

CompareAndSetBlockData will compare empty fields and set all elements in a block data to db

func (*BlockState) DeleteBlock added in v0.2.0

func (bs *BlockState) DeleteBlock(hash common.Hash) error

DeleteBlock deletes all instances of the block and its related data in the database

func (*BlockState) GenesisHash

func (bs *BlockState) GenesisHash() common.Hash

GenesisHash returns the hash of the genesis block

func (*BlockState) GetAllBlocksAtDepth

func (bs *BlockState) GetAllBlocksAtDepth(hash common.Hash) []common.Hash

GetAllBlocksAtDepth returns all hashes with the depth of the given hash plus one

func (*BlockState) GetArrivalTime

func (bs *BlockState) GetArrivalTime(hash common.Hash) (uint64, error)

GetArrivalTime returns the arrival time of a block given its hash

func (*BlockState) GetBabeHeader

func (bs *BlockState) GetBabeHeader(epoch uint64, slot uint64) (*types.BabeHeader, error)

GetBabeHeader retrieves a BabeHeader from the database

func (*BlockState) GetBlockBody

func (bs *BlockState) GetBlockBody(hash common.Hash) (*types.Body, error)

GetBlockBody will return Body for a given hash

func (*BlockState) GetBlockByHash

func (bs *BlockState) GetBlockByHash(hash common.Hash) (*types.Block, error)

GetBlockByHash returns a block for a given hash

func (*BlockState) GetBlockByNumber

func (bs *BlockState) GetBlockByNumber(num *big.Int) (*types.Block, error)

GetBlockByNumber returns a block for a given blockNumber

func (*BlockState) GetBlockHash

func (bs *BlockState) GetBlockHash(blockNumber *big.Int) (*common.Hash, error)

GetBlockHash returns block hash for a given blockNumber

func (*BlockState) GetFinalizedHash added in v0.2.0

func (bs *BlockState) GetFinalizedHash(round, setID uint64) (common.Hash, error)

GetFinalizedHash gets the latest finalized block header

func (*BlockState) GetFinalizedHeader added in v0.2.0

func (bs *BlockState) GetFinalizedHeader(round, setID uint64) (*types.Header, error)

GetFinalizedHeader returns the latest finalized block header

func (*BlockState) GetHeader

func (bs *BlockState) GetHeader(hash common.Hash) (*types.Header, error)

GetHeader returns a BlockHeader for a given hash

func (*BlockState) GetHeaderByNumber added in v0.2.0

func (bs *BlockState) GetHeaderByNumber(num *big.Int) (*types.Header, error)

GetHeaderByNumber returns a block header given a number

func (*BlockState) GetJustification

func (bs *BlockState) GetJustification(hash common.Hash) ([]byte, error)

GetJustification retrieves a Justification from the database

func (*BlockState) GetMessageQueue

func (bs *BlockState) GetMessageQueue(hash common.Hash) ([]byte, error)

GetMessageQueue retrieves a MessageQueue from the database

func (*BlockState) GetReceipt

func (bs *BlockState) GetReceipt(hash common.Hash) ([]byte, error)

GetReceipt retrieves a Receipt from the database

func (*BlockState) GetRound added in v0.2.0

func (bs *BlockState) GetRound() (uint64, error)

GetRound gets the latest finalized GRANDPA round from the db

func (*BlockState) GetSlotForBlock

func (bs *BlockState) GetSlotForBlock(hash common.Hash) (uint64, error)

GetSlotForBlock returns the slot for a block

func (*BlockState) HasArrivalTime added in v0.2.0

func (bs *BlockState) HasArrivalTime(hash common.Hash) (bool, error)

HasArrivalTime returns true if the db contains the block's arrival time

func (*BlockState) HasBlockBody added in v0.2.0

func (bs *BlockState) HasBlockBody(hash common.Hash) (bool, error)

HasBlockBody returns true if the db contains the block body

func (*BlockState) HasFinalizedBlock added in v0.2.0

func (bs *BlockState) HasFinalizedBlock(round, setID uint64) (bool, error)

HasFinalizedBlock returns true if there is a finalized block for a given round and setID, false otherwise

func (*BlockState) HasHeader

func (bs *BlockState) HasHeader(hash common.Hash) (bool, error)

HasHeader returns if the db contains a header with the given hash

func (*BlockState) HasJustification added in v0.2.0

func (bs *BlockState) HasJustification(hash common.Hash) (bool, error)

HasJustification returns if the db contains a Justification at the given hash

func (*BlockState) HasMessageQueue added in v0.2.0

func (bs *BlockState) HasMessageQueue(hash common.Hash) (bool, error)

HasMessageQueue returns if the db contains a MessageQueue at the given hash

func (*BlockState) HasReceipt added in v0.2.0

func (bs *BlockState) HasReceipt(hash common.Hash) (bool, error)

HasReceipt returns if the db contains a receipt at the given hash

func (*BlockState) HighestBlockHash

func (bs *BlockState) HighestBlockHash() common.Hash

HighestBlockHash returns the hash of the block with the highest number we have received This block may not necessarily be in the blocktree. TODO: can probably remove this once BlockResponses are implemented

func (*BlockState) HighestBlockNumber

func (bs *BlockState) HighestBlockNumber() *big.Int

HighestBlockNumber returns the largest block number we have seen This block may not necessarily be in the blocktree. TODO: can probably remove this once BlockResponses are implemented

func (*BlockState) HighestCommonAncestor

func (bs *BlockState) HighestCommonAncestor(a, b common.Hash) (common.Hash, error)

HighestCommonAncestor returns the block with the highest number that is an ancestor of both a and b

func (*BlockState) IsDescendantOf

func (bs *BlockState) IsDescendantOf(parent, child common.Hash) (bool, error)

IsDescendantOf returns true if child is a descendant of parent, false otherwise. it returns an error if parent or child are not in the blocktree.

func (*BlockState) Leaves

func (bs *BlockState) Leaves() []common.Hash

Leaves returns the leaves of the blocktree as an array

func (*BlockState) RegisterFinalizedChannel added in v0.2.0

func (bs *BlockState) RegisterFinalizedChannel(ch chan<- *types.Header) (byte, error)

RegisterFinalizedChannel registers a channel for block notification upon block finalization. It returns the channel ID (used for unregistering the channel)

func (*BlockState) RegisterImportedChannel added in v0.2.0

func (bs *BlockState) RegisterImportedChannel(ch chan<- *types.Block) (byte, error)

RegisterImportedChannel registers a channel for block notification upon block import. It returns the channel ID (used for unregistering the channel)

func (*BlockState) SetBabeHeader

func (bs *BlockState) SetBabeHeader(epoch uint64, slot uint64, bh *types.BabeHeader) error

SetBabeHeader sets a BabeHeader in the database

func (*BlockState) SetBlockBody

func (bs *BlockState) SetBlockBody(hash common.Hash, body *types.Body) error

SetBlockBody will add a block body to the db

func (*BlockState) SetFinalizedHash added in v0.2.0

func (bs *BlockState) SetFinalizedHash(hash common.Hash, round, setID uint64) error

SetFinalizedHash sets the latest finalized block header

func (*BlockState) SetHeader

func (bs *BlockState) SetHeader(header *types.Header) error

SetHeader will set the header into DB

func (*BlockState) SetJustification

func (bs *BlockState) SetJustification(hash common.Hash, data []byte) error

SetJustification sets a Justification in the database

func (*BlockState) SetMessageQueue

func (bs *BlockState) SetMessageQueue(hash common.Hash, data []byte) error

SetMessageQueue sets a MessageQueue in the database

func (*BlockState) SetReceipt

func (bs *BlockState) SetReceipt(hash common.Hash, data []byte) error

SetReceipt sets a Receipt in the database

func (*BlockState) SetRound added in v0.2.0

func (bs *BlockState) SetRound(round uint64) error

SetRound sets the latest finalized GRANDPA round in the db TODO: this needs to use both setID and round

func (*BlockState) SubChain

func (bs *BlockState) SubChain(start, end common.Hash) ([]common.Hash, error)

SubChain returns the sub-blockchain between the starting hash and the ending hash using the block tree

func (*BlockState) UnregisterFinalizedChannel added in v0.2.0

func (bs *BlockState) UnregisterFinalizedChannel(id byte)

UnregisterFinalizedChannel removes the block finalization notification channel with the given ID. A channel must be unregistered before closing it.

func (*BlockState) UnregisterImportedChannel added in v0.2.0

func (bs *BlockState) UnregisterImportedChannel(id byte)

UnregisterImportedChannel removes the block import notification channel with the given ID. A channel must be unregistered before closing it.

type EpochState added in v0.2.0

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

EpochState tracks information related to each epoch

func NewEpochState added in v0.2.0

func NewEpochState(db chaindb.Database) *EpochState

NewEpochState returns a new EpochState

func NewEpochStateFromGenesis added in v0.2.0

func NewEpochStateFromGenesis(db chaindb.Database, info *types.EpochInfo) (*EpochState, error)

NewEpochStateFromGenesis returns a new EpochState given information for the first epoch, fetched from the runtime

func (*EpochState) GetCurrentEpoch added in v0.2.0

func (s *EpochState) GetCurrentEpoch() (uint64, error)

GetCurrentEpoch returns the current epoch

func (*EpochState) GetEpochInfo added in v0.2.0

func (s *EpochState) GetEpochInfo(epoch uint64) (*types.EpochInfo, error)

GetEpochInfo returns the epoch info for a given epoch

func (*EpochState) GetStartSlotForEpoch added in v0.2.0

func (s *EpochState) GetStartSlotForEpoch(epoch uint64) (uint64, error)

GetStartSlotForEpoch returns the first slot in the given epoch. If 0 is passed as the epoch, it returns the start slot for the current epoch.

func (*EpochState) HasEpochInfo added in v0.2.0

func (s *EpochState) HasEpochInfo(epoch uint64) (bool, error)

HasEpochInfo returns whether epoch info exists for a given epoch

func (*EpochState) SetCurrentEpoch added in v0.2.0

func (s *EpochState) SetCurrentEpoch(epoch uint64) error

SetCurrentEpoch sets the current epoch

func (*EpochState) SetEpochInfo added in v0.2.0

func (s *EpochState) SetEpochInfo(epoch uint64, info *types.EpochInfo) error

SetEpochInfo sets the epoch info for a given epoch

type KeyValue added in v0.2.0

type KeyValue struct {
	Key   []byte
	Value []byte
}

KeyValue struct to hold key value pairs

type NetworkState

type NetworkState struct {
	Health       common.Health
	NetworkState common.NetworkState
	Peers        []common.PeerInfo
}

NetworkState defines fields for manipulating the state of network

func NewNetworkState

func NewNetworkState() *NetworkState

NewNetworkState creates NetworkState

func (*NetworkState) GetHealth

func (ns *NetworkState) GetHealth() common.Health

GetHealth retrieves network health from the database

func (*NetworkState) GetNetworkState

func (ns *NetworkState) GetNetworkState() common.NetworkState

GetNetworkState retrieves network state from the database

func (*NetworkState) GetPeers

func (ns *NetworkState) GetPeers() []common.PeerInfo

GetPeers retrieves network state from the database

func (*NetworkState) SetHealth

func (ns *NetworkState) SetHealth(health common.Health)

SetHealth sets network health in the database

func (*NetworkState) SetNetworkState

func (ns *NetworkState) SetNetworkState(networkState common.NetworkState)

SetNetworkState sets network state in the database

func (*NetworkState) SetPeers

func (ns *NetworkState) SetPeers(peers []common.PeerInfo)

SetPeers sets network state in the database

type Service

type Service struct {
	Storage     *StorageState
	Block       *BlockState
	Network     *NetworkState
	Transaction *TransactionState
	Epoch       *EpochState
	// contains filtered or unexported fields
}

Service is the struct that holds storage, block and network states

func NewService

func NewService(path string, lvl log.Lvl) *Service

NewService create a new instance of Service

func (*Service) DB

func (s *Service) DB() chaindb.Database

DB returns the Service's database

func (*Service) Initialize

func (s *Service) Initialize(data *genesis.Data, header *types.Header, t *trie.Trie, epochInfo *types.EpochInfo) error

Initialize initializes the genesis state of the DB using the given storage trie. The trie should be loaded with the genesis storage state. This only needs to be called during genesis initialization of the node; it doesn't need to be called during normal startup.

func (*Service) Start

func (s *Service) Start() error

Start initializes the Storage database and the Block database.

func (*Service) Stop

func (s *Service) Stop() error

Stop closes each state database

func (*Service) UseMemDB

func (s *Service) UseMemDB()

UseMemDB tells the service to use an in-memory key-value store instead of a persistent database. This should be called after NewService, and before Initialize. This should only be used for testing.

type StorageState

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

StorageState is the struct that holds the trie, db and lock

func NewStorageState

func NewStorageState(db chaindb.Database, blockState *BlockState, t *trie.Trie) (*StorageState, error)

NewStorageState creates a new StorageState backed by the given trie and database located at basePath.

func (*StorageState) Entries

func (s *StorageState) Entries(hash *common.Hash) (map[string][]byte, error)

Entries returns Entries from the trie

func (*StorageState) EnumeratedTrieRoot

func (s *StorageState) EnumeratedTrieRoot(values [][]byte)

EnumeratedTrieRoot not implemented

func (*StorageState) ExistsStorage

func (s *StorageState) ExistsStorage(hash *common.Hash, key []byte) (bool, error)

ExistsStorage check if the key exists in the storage trie with the given storage hash If no hash is provided, the current chain head is used

func (*StorageState) GetBalance

func (s *StorageState) GetBalance(hash *common.Hash, key [32]byte) (uint64, error)

GetBalance gets the balance for an account with the given public key

func (*StorageState) GetStorage

func (s *StorageState) GetStorage(hash *common.Hash, key []byte) ([]byte, error)

GetStorage gets the object from the trie using the given key and storage hash If no hash is provided, the current chain head is used

func (*StorageState) GetStorageByBlockHash added in v0.2.0

func (s *StorageState) GetStorageByBlockHash(bhash common.Hash, key []byte) ([]byte, error)

GetStorageByBlockHash returns the value at the given key at the given block hash

func (*StorageState) GetStorageChild

func (s *StorageState) GetStorageChild(hash *common.Hash, keyToChild []byte) (*trie.Trie, error)

GetStorageChild return GetChild from the trie

func (*StorageState) GetStorageFromChild

func (s *StorageState) GetStorageFromChild(hash *common.Hash, keyToChild, key []byte) ([]byte, error)

GetStorageFromChild return GetFromChild from the trie

func (*StorageState) LoadCode

func (s *StorageState) LoadCode(hash *common.Hash) ([]byte, error)

LoadCode returns the runtime code (located at :code)

func (*StorageState) LoadCodeHash

func (s *StorageState) LoadCodeHash(hash *common.Hash) (common.Hash, error)

LoadCodeHash returns the hash of the runtime code (located at :code)

func (*StorageState) LoadFromDB

func (s *StorageState) LoadFromDB(root common.Hash) (*trie.Trie, error)

LoadFromDB loads an encoded trie from the DB where the key is `root`

func (*StorageState) RegisterStorageChangeChannel added in v0.2.0

func (s *StorageState) RegisterStorageChangeChannel(ch chan<- *KeyValue) (byte, error)

RegisterStorageChangeChannel function to register storage change channels

func (*StorageState) StorageRoot

func (s *StorageState) StorageRoot() (common.Hash, error)

StorageRoot returns the root hash of the current storage trie

func (*StorageState) StoreInDB

func (s *StorageState) StoreInDB(root common.Hash) error

StoreInDB encodes the entire trie and writes it to the DB The key to the DB entry is the root hash of the trie

func (*StorageState) StoreTrie added in v0.2.0

func (s *StorageState) StoreTrie(root common.Hash, ts *TrieState) error

StoreTrie stores the given trie in the StorageState and writes it to the database

func (*StorageState) TrieState added in v0.2.0

func (s *StorageState) TrieState(hash *common.Hash) (*TrieState, error)

TrieState returns the TrieState for a given state root. If no state root is provided, it returns the TrieState for the current chain head.

func (*StorageState) UnregisterStorageChangeChannel added in v0.2.0

func (s *StorageState) UnregisterStorageChangeChannel(id byte)

UnregisterStorageChangeChannel removes the storage change notification channel with the given ID. A channel must be unregistered before closing it.

type TransactionState added in v0.2.0

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

TransactionState represents the queue of transactions

func NewTransactionState added in v0.2.0

func NewTransactionState() *TransactionState

NewTransactionState returns a new TransactionState

func (*TransactionState) AddToPool added in v0.2.0

AddToPool adds a transaction to the pool

func (*TransactionState) Peek added in v0.2.0

Peek returns the head of the queue without removing it

func (*TransactionState) Pending added in v0.2.0

Pending returns the current transactions in the queue and pool

func (*TransactionState) PendingInPool added in v0.2.0

func (s *TransactionState) PendingInPool() []*transaction.ValidTransaction

PendingInPool returns the current transactions in the pool

func (*TransactionState) Pop added in v0.2.0

Pop removes and returns the head of the queue

func (*TransactionState) Push added in v0.2.0

Push pushes a transaction to the queue, ordered by priority

func (*TransactionState) RemoveExtrinsic added in v0.2.0

func (s *TransactionState) RemoveExtrinsic(ext types.Extrinsic)

RemoveExtrinsic removes an extrinsic from the queue and pool

func (*TransactionState) RemoveExtrinsicFromPool added in v0.2.0

func (s *TransactionState) RemoveExtrinsicFromPool(ext types.Extrinsic)

RemoveExtrinsicFromPool removes an extrinsic from the pool

type TrieState added in v0.2.0

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

TrieState is a wrapper around a transient trie that is used during the course of executing some runtime call. If the execution of the call is successful, the trie will be saved in the StorageState.

func NewTrieState added in v0.2.0

func NewTrieState(db chaindb.Database, t *trie.Trie) (*TrieState, error)

NewTrieState returns a new TrieState with the given trie

func (*TrieState) ClearChildStorage added in v0.2.0

func (s *TrieState) ClearChildStorage(keyToChild, key []byte) error

ClearChildStorage removes the child storage entry from the trie

func (*TrieState) Commit added in v0.2.0

func (s *TrieState) Commit() error

nolint Commit ensures that the TrieState's trie and database match The database is the source of truth due to the runtime interpreter's undefined behaviour regarding the trie

func (*TrieState) Delete added in v0.2.0

func (s *TrieState) Delete(key []byte) error

Delete deletes a key from the trie

func (*TrieState) DeleteChildStorage added in v0.2.0

func (s *TrieState) DeleteChildStorage(key []byte) error

DeleteChildStorage deletes child storage from the trie

func (*TrieState) Entries added in v0.2.0

func (s *TrieState) Entries() map[string][]byte

Entries returns every key-value pair in the trie

func (*TrieState) Free added in v0.2.0

func (s *TrieState) Free() error

Free should be called once this trie state is no longer needed

func (*TrieState) Get added in v0.2.0

func (s *TrieState) Get(key []byte) ([]byte, error)

Get gets a value from the trie

func (*TrieState) GetBalance added in v0.2.0

func (s *TrieState) GetBalance(key [32]byte) (uint64, error)

GetBalance returns the balance for a given public key

func (*TrieState) GetChild added in v0.2.0

func (s *TrieState) GetChild(keyToChild []byte) (*trie.Trie, error)

GetChild returns the child trie at the given key

func (*TrieState) GetChildStorage added in v0.2.0

func (s *TrieState) GetChildStorage(keyToChild, key []byte) ([]byte, error)

GetChildStorage returns a value from a child trie

func (*TrieState) Has added in v0.2.0

func (s *TrieState) Has(key []byte) (bool, error)

Has returns whether or not a key exists

func (*TrieState) MustRoot added in v0.2.0

func (s *TrieState) MustRoot() common.Hash

MustRoot returns the trie's root hash. It panics if it fails to compute the root.

func (*TrieState) NextKey added in v0.2.0

func (s *TrieState) NextKey(key []byte) []byte

NextKey returns the next key in the trie in lexigraphical order. If it does not exist, it returns nil.

func (*TrieState) Root added in v0.2.0

func (s *TrieState) Root() (common.Hash, error)

Root returns the trie's root hash

func (*TrieState) Set added in v0.2.0

func (s *TrieState) Set(key []byte, value []byte) error

Set sets a key-value pair in the trie

func (*TrieState) SetBalance added in v0.2.0

func (s *TrieState) SetBalance(key [32]byte, balance uint64) error

SetBalance sets the balance for a given public key

func (*TrieState) SetChild added in v0.2.0

func (s *TrieState) SetChild(keyToChild []byte, child *trie.Trie) error

SetChild sets the child trie at the given key

func (*TrieState) SetChildStorage added in v0.2.0

func (s *TrieState) SetChildStorage(keyToChild, key, value []byte) error

SetChildStorage sets a key-value pair in a child trie

func (*TrieState) WriteTrieToDB added in v0.2.0

func (s *TrieState) WriteTrieToDB() error

WriteTrieToDB writes the trie to the database

Jump to

Keyboard shortcuts

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