Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidBodyType = errors.New("invalid body type")
ErrInvalidBodyType signals an invalid header pointer was provided
var ErrInvalidCacheSize = errors.New("cache size is invalid")
ErrInvalidCacheSize is raised when the given size for the cache is invalid
var ErrInvalidChainID = errors.New("invalid chain ID")
ErrInvalidChainID signals that an invalid chain ID has been provided
var ErrInvalidHeaderType = errors.New("invalid header type")
ErrInvalidHeaderType signals an invalid header pointer was provided
var ErrInvalidValue = errors.New("invalid value")
ErrInvalidValue signals that an invalid value has been provided such as NaN to an integer field
var ErrMiniBlockEmpty = errors.New("mini block is empty")
ErrMiniBlockEmpty signals that mini block is empty
var ErrNilAddressConverter = errors.New("nil address converter")
ErrNilAddressConverter signals that nil address converter was provided
var ErrNilBlockBody = errors.New("nil block body")
ErrNilBlockBody signals that block body is nil
var ErrNilBurnAddress = errors.New("nil burn address")
ErrNilBurnAddress signals that nil burn address was provided
var ErrNilCacher = errors.New("nil cacher")
ErrNilCacher signals that a nil cache has been provided
var ErrNilDatabase = errors.New("no database provided")
ErrNilDatabase is raised when a database operation is called, but no database is provided
var ErrNilElrondAddress = errors.New("nil elrond address")
ErrNilElrondAddress signals that nil elrond address was provided
var ErrNilHeadersDataPool = errors.New("nil headers data pool")
ErrNilHeadersDataPool signals that a nil header pool has been provided
var ErrNilHeadersNoncesDataPool = errors.New("nil headers nonces cache")
ErrNilHeadersNoncesDataPool signals that a nil header - nonce cache
var ErrNilMarshalizer = errors.New("no marshalizer provided")
ErrNilMarshalizer is raised when the NewTrie() function is called, but a marshalizer isn't provided
var ErrNilNodesCoordinator = errors.New("nil nodes coordinator")
ErrNilNodesCoordinator signals that nil shard coordinator was provided
var ErrNilShardCoordinator = errors.New("nil shard coordinator")
ErrNilShardCoordinator signals that nil shard coordinator was provided
var ErrWrongTypeAssertion = errors.New("wrong type assertion")
ErrWrongTypeAssertion signals that wrong type was provided
Functions ¶
This section is empty.
Types ¶
type BodyHandler ¶
type BodyHandler interface {
// IntegrityAndValidity checks the integrity and validity of the block
IntegrityAndValidity() error
// IsInterfaceNil returns true if there is no value under the interface
IsInterfaceNil() bool
}
BodyHandler interface for a block body
type ChainHandler ¶
type ChainHandler interface {
GetGenesisHeader() HeaderHandler
SetGenesisHeader(gb HeaderHandler) error
GetGenesisHeaderHash() []byte
SetGenesisHeaderHash(hash []byte)
GetCurrentBlockHeader() HeaderHandler
SetCurrentBlockHeader(bh HeaderHandler) error
GetCurrentBlockHeaderHash() []byte
SetCurrentBlockHeaderHash(hash []byte)
GetCurrentBlockBody() BodyHandler
SetCurrentBlockBody(body BodyHandler) error
GetLocalHeight() int64
SetLocalHeight(height int64)
GetNetworkHeight() int64
SetNetworkHeight(height int64)
HasBadBlock(blockHash []byte) bool
PutBadBlock(blockHash []byte)
IsInterfaceNil() bool
}
ChainHandler is the interface defining the functionality a blockchain should implement
type ConsensusRewardData ¶
ConsensusRewardData holds the required data for rewarding validators in a specific round and epoch
type DBRemoveCacher ¶
type DBRemoveCacher interface {
Put([]byte, [][]byte) error
Evict([]byte) ([][]byte, error)
GetSize() uint
IsInterfaceNil() bool
}
DBRemoveCacher is used to cache keys that will be deleted from the database
type DBWriteCacher ¶
type DBWriteCacher interface {
Put(key, val []byte) error
Get(key []byte) ([]byte, error)
Remove(key []byte) error
IsInterfaceNil() bool
}
DBWriteCacher is used to cache changes made to the trie, and only write to the database when it's needed
type HeaderHandler ¶
type HeaderHandler interface {
GetShardID() uint32
GetNonce() uint64
GetEpoch() uint32
GetRound() uint64
GetRootHash() []byte
GetValidatorStatsRootHash() []byte
GetPrevHash() []byte
GetPrevRandSeed() []byte
GetRandSeed() []byte
GetPubKeysBitmap() []byte
GetSignature() []byte
GetLeaderSignature() []byte
GetChainID() []byte
GetTimeStamp() uint64
GetTxCount() uint32
GetReceiptsHash() []byte
SetShardID(shId uint32)
SetNonce(n uint64)
SetEpoch(e uint32)
SetRound(r uint64)
SetTimeStamp(ts uint64)
SetRootHash(rHash []byte)
SetValidatorStatsRootHash(rHash []byte)
SetPrevHash(pvHash []byte)
SetPrevRandSeed(pvRandSeed []byte)
SetRandSeed(randSeed []byte)
SetPubKeysBitmap(pkbm []byte)
SetSignature(sg []byte)
SetLeaderSignature(sg []byte)
SetChainID(chainID []byte)
SetTxCount(txCount uint32)
IsStartOfEpochBlock() bool
GetMiniBlockHeadersWithDst(destId uint32) map[string]uint32
IsInterfaceNil() bool
ItemsInBody() uint32
ItemsInHeader() uint32
Clone() HeaderHandler
CheckChainID(reference []byte) error
}
HeaderHandler defines getters and setters for header data holder
func TrimHeaderHandlerSlice ¶
func TrimHeaderHandlerSlice(in []HeaderHandler) []HeaderHandler
TrimHeaderHandlerSlice creates a copy of the provided slice without the excess capacity
type StorageManager ¶
type StorageManager interface {
Database() DBWriteCacher
SetDatabase(cacher DBWriteCacher)
TakeSnapshot([]byte, marshal.Marshalizer, hashing.Hasher)
SetCheckpoint([]byte, marshal.Marshalizer, hashing.Hasher)
Prune([]byte) error
CancelPrune([]byte)
MarkForEviction([]byte, [][]byte) error
GetDbThatContainsHash([]byte) DBWriteCacher
Clone() StorageManager
IsPruningEnabled() bool
IsInterfaceNil() bool
}
StorageManager manages all trie storage operations
type TransactionHandler ¶
type TransactionHandler interface {
IsInterfaceNil() bool
GetValue() *big.Int
GetNonce() uint64
GetData() []byte
GetRecvAddress() []byte
GetSndAddress() []byte
GetGasLimit() uint64
GetGasPrice() uint64
SetValue(*big.Int)
SetData([]byte)
SetRecvAddress([]byte)
SetSndAddress([]byte)
}
TransactionHandler defines the type of executable transaction
type Trie ¶
type Trie interface {
Get(key []byte) ([]byte, error)
Update(key, value []byte) error
Delete(key []byte) error
Root() ([]byte, error)
Prove(key []byte) ([][]byte, error)
VerifyProof(proofs [][]byte, key []byte) (bool, error)
Commit() error
Recreate(root []byte) (Trie, error)
String() string
DeepClone() (Trie, error)
CancelPrune(rootHash []byte, identifier TriePruningIdentifier)
Prune(rootHash []byte, identifier TriePruningIdentifier) error
TakeSnapshot(rootHash []byte)
SetCheckpoint(rootHash []byte)
ResetOldHashes() [][]byte
AppendToOldHashes([][]byte)
Database() DBWriteCacher
GetSerializedNodes([]byte, uint64) ([][]byte, error)
GetAllLeaves() (map[string][]byte, error)
IsPruningEnabled() bool
IsInterfaceNil() bool
}
Trie is an interface for Merkle Trees implementations
type TrieFactory ¶
TrieFactory creates new tries
type TriePruningIdentifier ¶
type TriePruningIdentifier byte
TriePruningIdentifier is the type for trie pruning identifiers
const ( // OldRoot is appended to the key when oldHashes are added to the evictionWaitingList OldRoot TriePruningIdentifier = 0 // NewRoot is appended to the key when newHashes are added to the evictionWaitingList NewRoot TriePruningIdentifier = 1 )
type TrieSyncer ¶
TrieSyncer synchronizes the trie, asking on the network for the missing nodes