data

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: GPL-3.0 Imports: 4 Imported by: 2

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 ErrInvalidTypeAssertion = errors.New("invalid type assertion")

ErrInvalidTypeAssertion signals an invalid type assertion

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 ErrNilPointerDereference = errors.New("nil pointer dereference")

ErrNilPointerDereference signals that a nil pointer dereference was detected and avoided

View Source
var ErrNilPointerReceiver = errors.New("nil pointer receiver")

ErrNilPointerReceiver signals that a nil pointer receiver was used

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 ErrNilScheduledRootHash = errors.New("scheduled root hash is nil")

ErrNilScheduledRootHash signals that a nil scheduled root hash was used

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 ErrScheduledRootHashNotSupported = errors.New("scheduled root hash is not supported")

ErrScheduledRootHashNotSupported signals that a scheduled root hash is not supported

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

ErrTimeIsOut signals that time is out

View Source
var ErrWrongTransactionsTypeSize = errors.New("wrong transactions type size")

ErrWrongTransactionsTypeSize signals that size of transactions type buffer from mini block reserved field is wrong

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
	SetCurrentBlockHeaderAndRootHash(bh HeaderHandler, rootHash []byte) error
	GetCurrentBlockHeaderHash() []byte
	SetCurrentBlockHeaderHash(hash []byte)
	GetCurrentBlockRootHash() []byte
	SetFinalBlockInfo(nonce uint64, blockHash []byte, rootHash []byte)
	GetFinalBlockInfo() (nonce uint64, blockHash []byte, rootHash []byte)
	IsInterfaceNil() bool
}

ChainHandler is the interface defining the functionality a blockchain should implement

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 EconomicsHandler

type EconomicsHandler interface {
	GetTotalSupply() *big.Int
	GetTotalToDistribute() *big.Int
	GetTotalNewlyMinted() *big.Int
	GetRewardsPerBlock() *big.Int
	GetRewardsForProtocolSustainability() *big.Int
	GetNodePrice() *big.Int
	GetPrevEpochStartRound() uint64
	GetPrevEpochStartHash() []byte

	SetTotalSupply(totalSupply *big.Int) error
	SetTotalToDistribute(totalToDistribute *big.Int) error
	SetTotalNewlyMinted(totalNewlyMinted *big.Int) error
	SetRewardsPerBlock(rewardsPerBlock *big.Int) error
	SetRewardsForProtocolSustainability(rewardsForProtocolSustainability *big.Int) error
	SetNodePrice(nodePrice *big.Int) error
	SetPrevEpochStartRound(prevEpochStartRound uint64) error
	SetPrevEpochStartHash(prevEpochStartHash []byte) error
}

EconomicsHandler defines setters and getters for Economics

type EpochStartHandler

type EpochStartHandler interface {
	GetLastFinalizedHeaderHandlers() []EpochStartShardDataHandler
	GetEconomicsHandler() EconomicsHandler

	SetLastFinalizedHeaders(epochStartShardDataHandlers []EpochStartShardDataHandler) error
	SetEconomics(economicsHandler EconomicsHandler) error
}

EpochStartHandler defines setters and getters for EpochStart

type EpochStartShardDataHandler

type EpochStartShardDataHandler interface {
	GetShardID() uint32
	GetEpoch() uint32
	GetRound() uint64
	GetNonce() uint64
	GetHeaderHash() []byte
	GetRootHash() []byte
	GetFirstPendingMetaBlock() []byte
	GetLastFinishedMetaBlock() []byte
	GetPendingMiniBlockHeaderHandlers() []MiniBlockHeaderHandler

	SetShardID(uint32) error
	SetEpoch(uint32) error
	SetRound(uint64) error
	SetNonce(uint64) error
	SetHeaderHash([]byte) error
	SetRootHash([]byte) error
	SetFirstPendingMetaBlock([]byte) error
	SetLastFinishedMetaBlock([]byte) error
	SetPendingMiniBlockHeaders([]MiniBlockHeaderHandler) error
}

EpochStartShardDataHandler defines setters and getters for EpochStartShardData

type EventHandler

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

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
	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
	GetReserved() []byte
	GetMiniBlockHeadersWithDst(destId uint32) map[string]uint32
	GetOrderedCrossMiniblocksWithDst(destId uint32) []*MiniBlockInfo
	GetMiniBlockHeadersHashes() [][]byte
	GetMiniBlockHeaderHandlers() []MiniBlockHeaderHandler
	HasScheduledSupport() bool
	GetAdditionalData() headerVersionData.HeaderAdditionalData
	HasScheduledMiniBlocks() bool

	SetAccumulatedFees(value *big.Int) error
	SetDeveloperFees(value *big.Int) error
	SetShardID(shId uint32) error
	SetNonce(n uint64) error
	SetEpoch(e uint32) error
	SetRound(r uint64) error
	SetTimeStamp(ts uint64) error
	SetRootHash(rHash []byte) error
	SetPrevHash(pvHash []byte) error
	SetPrevRandSeed(pvRandSeed []byte) error
	SetRandSeed(randSeed []byte) error
	SetPubKeysBitmap(pkbm []byte) error
	SetSignature(sg []byte) error
	SetLeaderSignature(sg []byte) error
	SetChainID(chainID []byte) error
	SetSoftwareVersion(version []byte) error
	SetTxCount(txCount uint32) error
	SetMiniBlockHeaderHandlers(mbHeaderHandlers []MiniBlockHeaderHandler) error
	SetReceiptsHash(hash []byte) error
	SetScheduledRootHash(rootHash []byte) error
	ValidateHeaderVersion() error
	SetAdditionalData(headerVersionData headerVersionData.HeaderAdditionalData) error
	IsStartOfEpochBlock() bool
	ShallowClone() HeaderHandler
	IsInterfaceNil() bool
}

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 LogData

type LogData struct {
	LogHandler
	TxHash string
}

LogData holds the data needed for indexing logs and events

type LogHandler

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 MetaHeaderHandler

type MetaHeaderHandler interface {
	HeaderHandler
	GetValidatorStatsRootHash() []byte
	GetEpochStartHandler() EpochStartHandler
	GetDevFeesInEpoch() *big.Int
	GetShardInfoHandlers() []ShardDataHandler
	SetValidatorStatsRootHash(rHash []byte) error
	SetDevFeesInEpoch(value *big.Int) error
	SetShardInfoHandlers(shardInfo []ShardDataHandler) error
	SetAccumulatedFeesInEpoch(value *big.Int) error
}

MetaHeaderHandler defines getters and setters for the meta block header

type MiniBlockHeaderHandler

type MiniBlockHeaderHandler interface {
	GetHash() []byte
	GetSenderShardID() uint32
	GetReceiverShardID() uint32
	GetTxCount() uint32
	GetTypeInt32() int32
	GetReserved() []byte
	GetProcessingType() int32
	GetConstructionState() int32
	IsFinal() bool
	GetIndexOfFirstTxProcessed() int32
	GetIndexOfLastTxProcessed() int32

	SetHash(hash []byte) error
	SetSenderShardID(shardID uint32) error
	SetReceiverShardID(shardID uint32) error
	SetTxCount(count uint32) error
	SetTypeInt32(t int32) error
	SetReserved(reserved []byte) error
	SetProcessingType(procType int32) error
	SetConstructionState(state int32) error
	SetIndexOfLastTxProcessed(indexOfLastTxProcessed int32) error
	SetIndexOfFirstTxProcessed(indexOfFirstTxProcessed int32) error
	ShallowClone() MiniBlockHeaderHandler
}

MiniBlockHeaderHandler defines setters and getters for miniBlock headers

type MiniBlockInfo

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

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

type PeerChangeHandler

type PeerChangeHandler interface {
	GetPubKey() []byte
	GetShardIdDest() uint32

	SetPubKey(pubKey []byte) error
	SetShardIdDest(shardID uint32) error
}

PeerChangeHandler defines setters and getters for PeerChange

type ShardDataHandler

type ShardDataHandler interface {
	GetHeaderHash() []byte
	GetShardMiniBlockHeaderHandlers() []MiniBlockHeaderHandler
	GetPrevRandSeed() []byte
	GetPubKeysBitmap() []byte
	GetSignature() []byte
	GetRound() uint64
	GetPrevHash() []byte
	GetNonce() uint64
	GetAccumulatedFees() *big.Int
	GetDeveloperFees() *big.Int
	GetNumPendingMiniBlocks() uint32
	GetLastIncludedMetaNonce() uint64
	GetShardID() uint32
	GetTxCount() uint32

	SetHeaderHash(hash []byte) error
	SetShardMiniBlockHeaderHandlers(mbHeaderHandlers []MiniBlockHeaderHandler) error
	SetPrevRandSeed(prevRandSeed []byte) error
	SetPubKeysBitmap(pubKeysBitmap []byte) error
	SetSignature(signature []byte) error
	SetRound(round uint64) error
	SetPrevHash(prevHash []byte) error
	SetNonce(nonce uint64) error
	SetAccumulatedFees(fees *big.Int) error
	SetDeveloperFees(fees *big.Int) error
	SetNumPendingMiniBlocks(num uint32) error
	SetLastIncludedMetaNonce(nonce uint64) error
	SetShardID(shardID uint32) error
	SetTxCount(txCount uint32) error

	ShallowClone() ShardDataHandler
}

ShardDataHandler defines setters and getters for ShardDataHandler

type ShardHeaderHandler

type ShardHeaderHandler interface {
	HeaderHandler
	GetMetaBlockHashes() [][]byte
	GetEpochStartMetaHash() []byte
	SetEpochStartMetaHash(hash []byte) error
	GetBlockBodyTypeInt32() int32
	SetMetaBlockHashes(hashes [][]byte) error
	MapMiniBlockHashesToShards() map[string]uint32
}

ShardHeaderHandler defines getters and setters for the shard block header

type ShardValidatorInfoHandler

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

ShardValidatorInfoHandler is used to store multiple validatorInfo properties required in shards

type SyncStatisticsHandler

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 TransactionWithFeeHandler

type TransactionWithFeeHandler interface {
	GetGasLimit() uint64
	GetGasPrice() uint64
	GetData() []byte
	GetRcvAddr() []byte
	GetValue() *big.Int
}

TransactionWithFeeHandler represents a transaction structure that has economics variables defined

type TriggerRegistryHandler

type TriggerRegistryHandler interface {
	GetIsEpochStart() bool
	GetNewEpochHeaderReceived() bool
	GetEpoch() uint32
	GetMetaEpoch() uint32
	GetCurrentRoundIndex() int64
	GetEpochStartRound() uint64
	GetEpochFinalityAttestingRound() uint64
	GetEpochMetaBlockHash() []byte
	GetEpochStartHeaderHandler() HeaderHandler

	SetIsEpochStart(isEpochStart bool) error
	SetNewEpochHeaderReceived(newEpochHeaderReceived bool) error
	SetEpoch(epoch uint32) error
	SetMetaEpoch(metaEpoch uint32) error
	SetCurrentRoundIndex(roundIndex int64) error
	SetEpochStartRound(startRound uint64) error
	SetEpochFinalityAttestingRound(finalityAttestingRound uint64) error
	SetEpochMetaBlockHash(epochMetaBlockHash []byte) error
	SetEpochStartHeaderHandler(epochStartHeaderHandler HeaderHandler) error
}

TriggerRegistryHandler defines getters and setters for the trigger registry

type UserAccountHandler

type UserAccountHandler interface {
	RetrieveValueFromDataTrieTracker(key []byte) ([]byte, error)
	GetBalance() *big.Int
	GetNonce() uint64
	AddressBytes() []byte
	IsInterfaceNil() bool
}

UserAccountHandler models a user account

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