data

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidCacheSize = errors.New("cache size is invalid")

ErrInvalidCacheSize is raised when the given size for the cache is invalid

View Source
var ErrInvalidHeaderType = errors.New("invalid header type")

ErrInvalidHeaderType signals an invalid header pointer was provided

View Source
var ErrInvalidUserNameLength = errors.New("invalid user name length")

ErrInvalidUserNameLength signals that provided user name length is invalid

View Source
var ErrInvalidValue = errors.New("invalid value")

ErrInvalidValue signals that an invalid value has been provided such as NaN to an integer field

View Source
var ErrLeafSizeTooBig = errors.New("leaf size too big")

ErrLeafSizeTooBig signals that the value size of the leaf is too big

View Source
var ErrMiniBlockEmpty = errors.New("mini block is empty")

ErrMiniBlockEmpty signals that mini block is empty

View Source
var ErrNegativeValue = errors.New("negative value")

ErrNegativeValue signals that a negative value has been detected and it is not allowed

View Source
var ErrNilBlockBody = errors.New("nil block body")

ErrNilBlockBody signals that block body is nil

View Source
var ErrNilCacher = errors.New("nil cacher")

ErrNilCacher signals that a nil cache has been provided

View Source
var ErrNilDatabase = errors.New("no database provided")

ErrNilDatabase is raised when a database operation is called, but no database is provided

View Source
var ErrNilMarshalizer = errors.New("no marshalizer provided")

ErrNilMarshalizer is raised when the NewTrie() function is called, but a marshalizer isn't provided

View Source
var ErrNilRcvAddr = errors.New("nil receiver address")

ErrNilRcvAddr signals that an operation has been attempted to or with a nil receiver address

View Source
var ErrNilShardCoordinator = errors.New("nil shard coordinator")

ErrNilShardCoordinator signals that nil shard coordinator was provided

View Source
var ErrNilSignature = errors.New("nil signature")

ErrNilSignature signals that a operation has been attempted with a nil signature

View Source
var ErrNilSndAddr = errors.New("nil sender address")

ErrNilSndAddr signals that an operation has been attempted to or with a nil sender address

View Source
var ErrNilThrottler = errors.New("nil throttler")

ErrNilThrottler signals that nil throttler has been provided

View Source
var ErrNilTxHash = errors.New("nil transaction hash")

ErrNilTxHash signals that an operation has been attempted with a nil hash

View Source
var ErrNilValue = errors.New("nil value")

ErrNilValue signals the value is nil

View Source
var ErrTimeIsOut = errors.New("time is out")

ErrTimeIsOut signals that time is out

Functions

This section is empty.

Types

type BigIntCaster

type BigIntCaster struct{}

BigIntCaster handles big int operations

func (*BigIntCaster) Equal

func (c *BigIntCaster) Equal(a, b *big.Int) bool

Equal returns true if the provided big ints are equal

func (*BigIntCaster) MarshalTo

func (c *BigIntCaster) MarshalTo(a *big.Int, buf []byte) (int, error)

MarshalTo marshals the first parameter to the second one

func (*BigIntCaster) NewPopulated

func (c *BigIntCaster) NewPopulated() *big.Int

NewPopulated returns a new instance of a big int, pre-populated with a zero

func (*BigIntCaster) Size

func (c *BigIntCaster) Size(a *big.Int) int

Size returns the size of a big int

func (*BigIntCaster) Unmarshal

func (c *BigIntCaster) Unmarshal(buf []byte) (*big.Int, error)

Unmarshal unmarshalls the parameter to a big int

type BodyHandler

type BodyHandler interface {
	Clone() BodyHandler
	// 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)
	IsInterfaceNil() bool
	CreateNewHeader() HeaderHandler
}

ChainHandler is the interface defining the functionality a blockchain should implement

type CheckpointHashesHolder added in v1.2.4

type CheckpointHashesHolder interface {
	Put(rootHash []byte, hashes ModifiedHashes) bool
	RemoveCommitted(lastCommittedRootHash []byte)
	Remove(hash []byte)
	ShouldCommit(hash []byte) bool
	IsInterfaceNil() bool
}

CheckpointHashesHolder is used to hold the hashes that need to be committed in the future state checkpoint

type ConsensusRewardData

type ConsensusRewardData struct {
	Round     uint64
	Epoch     uint32
	PubKeys   []string
	Addresses []string
}

ConsensusRewardData holds the required data for rewarding validators in a specific round and epoch

type DBWriteCacher

type DBWriteCacher interface {
	Put(key, val []byte) error
	Get(key []byte) ([]byte, error)
	Remove(key []byte) error
	Close() error
	IsInterfaceNil() bool
}

DBWriteCacher is used to cache changes made to the trie, and only write to the database when it's needed

type EventHandler added in v1.0.104

type EventHandler interface {
	// GetAddress returns the address of the contract that generated this event
	//  - in sc calling another sc situation this will differ from the
	//    LogHandler's GetAddress, whereas in the single sc situation
	//    they will be the same
	GetAddress() []byte
	// GetIdentifier returns identifier of the event, that together with the ABI can
	//   be used to understand the type of the event by other applications
	GetIdentifier() []byte
	// GetTopics returns the data that can be indexed so that it would be searchable
	//  by other applications
	GetTopics() [][]byte
	// GetData returns the rest of the event data, which will not be indexed, so storing
	//  information here should be cheaper
	GetData() []byte

	IsInterfaceNil() bool
}

EventHandler defines the type for an event resulted from a smart contract call contained in a log

type GoRoutineThrottler added in v1.0.126

type GoRoutineThrottler interface {
	CanProcess() bool
	StartProcessing()
	EndProcessing()
	IsInterfaceNil() bool
}

GoRoutineThrottler can monitor the number of the currently running go routines

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
	GetSoftwareVersion() []byte
	GetTimeStamp() uint64
	GetTxCount() uint32
	GetReceiptsHash() []byte
	GetAccumulatedFees() *big.Int
	GetDeveloperFees() *big.Int
	GetEpochStartMetaHash() []byte
	GetReserved() []byte

	SetAccumulatedFees(value *big.Int)
	SetDeveloperFees(value *big.Int)
	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)
	SetSoftwareVersion(version []byte)
	SetTxCount(txCount uint32)

	IsStartOfEpochBlock() bool
	GetMiniBlockHeadersWithDst(destId uint32) map[string]uint32
	GetOrderedCrossMiniblocksWithDst(destId uint32) []*MiniBlockInfo
	GetMiniBlockHeadersHashes() [][]byte

	IsInterfaceNil() bool
	Clone() HeaderHandler
}

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 LogHandler added in v1.0.104

type LogHandler interface {
	// GetAddress returns the address of the sc that was originally called by the user
	GetAddress() []byte
	// GetLogEvents returns the events from a transaction log entry
	GetLogEvents() []EventHandler

	IsInterfaceNil() bool
}

LogHandler defines the type for a log resulted from executing a transaction or smart contract call

type MiniBlockInfo added in v1.1.1

type MiniBlockInfo struct {
	Hash          []byte
	SenderShardID uint32
	Round         uint64
}

MiniBlockInfo holds information about a cross miniblock referenced in a received block

type ModifiedHashes

type ModifiedHashes map[string]struct{}

ModifiedHashes is used to memorize all old hashes and new hashes from when a trie is committed

func (ModifiedHashes) Clone added in v1.2.4

func (mh ModifiedHashes) Clone() ModifiedHashes

Clone is used to create a clone of the map

type NumNodesDTO added in v1.1.45

type NumNodesDTO struct {
	Leaves     int
	Extensions int
	Branches   int
	MaxLevel   int
}

NumNodesDTO represents the DTO structure that will hold the number of nodes split by category and other trie structure relevant data such as maximum number of trie levels including the roothash node and all leaves

type ShardValidatorInfoHandler added in v0.0.5

type ShardValidatorInfoHandler interface {
	GetPublicKey() []byte
	GetTempRating() uint32
	String() string
	IsInterfaceNil() bool
}

ShardValidatorInfoHandler is used to store multiple validatorInfo properties required in shards

type SnapshotDbHandler added in v1.0.132

type SnapshotDbHandler interface {
	DBWriteCacher
	IsInUse() bool
	DecreaseNumReferences()
	IncreaseNumReferences()
	MarkForRemoval()
	MarkForDisconnection()
	SetPath(string)
}

SnapshotDbHandler is used to keep track of how many references a snapshot db has

type StorageManager

type StorageManager interface {
	Database() DBWriteCacher
	TakeSnapshot([]byte, bool, chan core.KeyValueHolder)
	SetCheckpoint([]byte, chan core.KeyValueHolder)
	GetSnapshotThatContainsHash(rootHash []byte) SnapshotDbHandler
	IsPruningEnabled() bool
	IsPruningBlocked() bool
	EnterPruningBufferingMode()
	ExitPruningBufferingMode()
	GetSnapshotDbBatchDelay() int
	AddDirtyCheckpointHashes([]byte, ModifiedHashes) bool
	Remove(hash []byte) error
	Close() error
	IsInterfaceNil() bool
}

StorageManager manages all trie storage operations

type SyncStatisticsHandler added in v1.1.12

type SyncStatisticsHandler interface {
	Reset()
	AddNumReceived(value int)
	AddNumLarge(value int)
	SetNumMissing(rootHash []byte, value int)
	NumReceived() int
	NumLarge() int
	NumMissing() int
	IsInterfaceNil() bool
}

SyncStatisticsHandler defines the methods for a component able to store the sync statistics for a trie

type TransactionHandler

type TransactionHandler interface {
	IsInterfaceNil() bool

	GetValue() *big.Int
	GetNonce() uint64
	GetData() []byte
	GetRcvAddr() []byte
	GetRcvUserName() []byte
	GetSndAddr() []byte
	GetGasLimit() uint64
	GetGasPrice() uint64

	SetValue(*big.Int)
	SetData([]byte)
	SetRcvAddr([]byte)
	SetSndAddr([]byte)
	Size() int

	CheckIntegrity() error
}

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
	RootHash() ([]byte, error)
	Commit() error
	Recreate(root []byte) (Trie, error)
	String() string
	GetObsoleteHashes() [][]byte
	GetDirtyHashes() (ModifiedHashes, error)
	GetOldRoot() []byte
	GetSerializedNodes([]byte, uint64) ([][]byte, uint64, error)
	GetSerializedNode([]byte) ([]byte, error)
	GetNumNodes() NumNodesDTO
	GetAllLeavesOnChannel(rootHash []byte) (chan core.KeyValueHolder, error)
	GetAllHashes() ([][]byte, error)
	GetProof(key []byte) ([][]byte, error)
	VerifyProof(key []byte, proof [][]byte) (bool, error)
	GetStorageManager() StorageManager
	Close() error
	IsInterfaceNil() bool
}

Trie is an interface for Merkle Trees implementations

type TrieCreateArgs added in v1.2.5

type TrieCreateArgs struct {
	TrieStorageConfig  config.StorageConfig
	ShardID            string
	PruningEnabled     bool
	CheckpointsEnabled bool
	MaxTrieLevelInMem  uint
}

TrieCreateArgs holds arguments for calling the Create method on the TrieFactory

type TrieFactory

type TrieFactory interface {
	Create(TrieCreateArgs) (StorageManager, Trie, error)
	IsInterfaceNil() bool
}

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

type TrieSyncer interface {
	StartSyncing(rootHash []byte, ctx context.Context) error
	IsInterfaceNil() bool
}

TrieSyncer synchronizes the trie, asking on the network for the missing nodes

type ValidatorInfoHandler

type ValidatorInfoHandler interface {
	GetPublicKey() []byte
	GetShardId() uint32
	GetList() string
	GetIndex() uint32
	GetTempRating() uint32
	GetRating() uint32
	String() string
	IsInterfaceNil() bool
}

ValidatorInfoHandler is used to store multiple validatorInfo properties

Jump to

Keyboard shortcuts

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