Documentation ¶
Index ¶
- Variables
- func GetShardHeader(hash []byte, cacher storage.Cacher, marshalizer marshal.Marshalizer, ...) (*block.Header, error)
- func GetShardHeaderFromPool(hash []byte, cacher storage.Cacher) (*block.Header, error)
- func GetShardHeaderFromStorage(hash []byte, marshalizer marshal.Marshalizer, ...) (*block.Header, error)
- func ShardCacherIdentifier(senderShardId uint32, destinationShardId uint32) string
- type BlockHeaderState
- type BlockProcessor
- type BlocksTracker
- type Bootstrapper
- type Checker
- type ChronologyValidator
- type DataPacker
- type ForkDetector
- type HashAccesser
- type InterceptedBlockBody
- type Interceptor
- type InterceptorsContainer
- type InterceptorsContainerFactory
- type MessageHandler
- type RequiredDataPool
- type SigVerifier
- type SignedDataValidator
- type TopicHandler
- type TopicMessageHandler
- type TransactionProcessor
Constants ¶
This section is empty.
Variables ¶
var ErrAccountStateDirty = errors.New("accountState was dirty before starting to change")
ErrAccountStateDirty signals that the accounts were modified before starting the current modification
var ErrContainerKeyAlreadyExists = errors.New("provided key already exists in container")
ErrContainerKeyAlreadyExists signals that an element was already set in the container's map
var ErrCouldNotDecodeUnderlyingBody = errors.New("could not decode InterceptedBlockBody to block.Body")
ErrCouldNotDecodeUnderlyingBody signals that an InterceptedBlockBody could not be decoded to a block.Body using type assertion
var ErrHeaderNotFinal = errors.New("header in metablock is not final")
ErrHeaderNotFinal signals that header is not final and it should be
var ErrHigherNonceInTransaction = errors.New("higher nonce in transaction")
ErrHigherNonceInTransaction signals the nonce in transaction is higher than the account's nonce
var ErrInsufficientFunds = errors.New("insufficient funds")
ErrInsufficientFunds signals the funds are insufficient
var ErrInvalidBlockBodyType = errors.New("invalid block body type")
ErrInvalidBlockBodyType signals that an operation has been attempted with an invalid block body type
var ErrInvalidBlockHash = errors.New("invalid block hash")
ErrInvalidBlockHash signals the hash of the block is not matching with the previous one
var ErrInvalidContainerKey = errors.New("element does not exist in container")
ErrInvalidContainerKey signals that an element does not exist in the container's map
var ErrInvalidRcvAddr = errors.New("invalid receiver address")
ErrInvalidRcvAddr signals that an operation has been attempted to or with an invalid receiver address
var ErrInvalidShardId = errors.New("invalid shard id")
ErrInvalidShardId signals that the shard id is invalid
var ErrInvalidSndAddr = errors.New("invalid sender address")
ErrInvalidSndAddr signals that an operation has been attempted to or with an invalid sender address
var ErrInvalidTxInPool = errors.New("invalid transaction in the transactions pool")
ErrInvalidTxInPool signals an invalid transaction in the transactions pool
var ErrLastNotarizedHdrsSliceIsNil = errors.New("last notarized shard headers slice is nil")
ErrLastNotarizedHdrsSliceIsNil signals that the slice holding last notarized headers is nil
var ErrLenMismatch = errors.New("lengths mismatch")
ErrLenMismatch signals that 2 or more slices have different lengths
var ErrLowShardHeaderRound = errors.New("shard header round is lower than last committed for this shard")
ErrLowShardHeaderRound signals that shard header round is too low for processing
var ErrLowerNonceInTransaction = errors.New("lower nonce in transaction")
ErrLowerNonceInTransaction signals the nonce in transaction is lower than the account's nonce
var ErrMarshalWithoutSuccess = errors.New("marshal without success")
ErrMarshalWithoutSuccess signals that marshal some data was not done with success
var ErrMintAddressNotInThisShard = errors.New("mint address does not belong to current shard")
ErrMintAddressNotInThisShard signals that the mint address does not belong to current shard
var ErrMissingBody = errors.New("missing body")
ErrMissingBody signals that body of the block is missing
var ErrMissingHeader = errors.New("missing header")
ErrMissingHeader signals that header of the block is missing
var ErrMissingTransaction = errors.New("missing transaction")
ErrMissingTransaction signals that one transaction is missing
var ErrNegativeValue = errors.New("negative value")
ErrNegativeValue signals that a negative value has been detected and it is not allowed
var ErrNilAccountsAdapter = errors.New("nil AccountsAdapter")
ErrNilAccountsAdapter defines the error when trying to use a nil AccountsAddapter
var ErrNilAddressContainer = errors.New("nil AddressContainer")
ErrNilAddressContainer signals that an operation has been attempted to or with a nil AddressContainer implementation
var ErrNilAddressConverter = errors.New("nil AddressConverter")
ErrNilAddressConverter signals that an operation has been attempted to or with a nil AddressConverter implementation
var ErrNilBlockBody = errors.New("nil block body")
ErrNilBlockBody signals that an operation has been attempted to or with a nil block body
var ErrNilBlockBodyStorage = errors.New("nil block body storage")
ErrNilBlockBodyStorage signals that a nil block body storage has been provided
var ErrNilBlockChain = errors.New("nil block chain")
ErrNilBlockChain signals that an operation has been attempted to or with a nil blockchain
var ErrNilBlockExecutor = errors.New("nil BlockExecutor")
ErrNilBlockExecutor signals that an operation has been attempted to or with a nil BlockExecutor implementation
var ErrNilBlockHeader = errors.New("nil block header")
ErrNilBlockHeader signals that an operation has been attempted to or with a nil block header
var ErrNilBlocksTracker = errors.New("nil blocks tracker")
ErrNilBlocksTracker signals that a nil blocks tracker has been provided
var ErrNilBuffer = errors.New("provided byte buffer is nil")
ErrNilBuffer signals that a provided byte buffer is nil
var ErrNilCacher = errors.New("nil cacher")
ErrNilCacher signals that a nil cache has been provided
var ErrNilChronologyValidator = errors.New("provided chronology validator object is nil")
ErrNilChronologyValidator signals that a nil chronology validator has been provided
var ErrNilContainerElement = errors.New("element cannot be nil")
ErrNilContainerElement signals when trying to add a nil element in the container
var ErrNilDataPoolHolder = errors.New("nil data pool holder")
ErrNilDataPoolHolder signals that the data pool holder is nil
var ErrNilDataToProcess = errors.New("nil data to process")
ErrNilDataToProcess signals that nil data was provided
var ErrNilForkDetector = errors.New("nil fork detector")
ErrNilForkDetector signals that the fork detector is nil
var ErrNilHasher = errors.New("nil Hasher")
ErrNilHasher signals that an operation has been attempted to or with a nil hasher implementation
var ErrNilHaveTimeHandler = errors.New("nil have time handler")
ErrNilHaveTimeHandler signals that a nil have time handler func was provided
var ErrNilHeadersBlocks = errors.New("nil genesis headers blocks map")
ErrNilHeadersBlocks signals that a nil shard genesis headers map has been 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 ErrNilHeadersStorage = errors.New("nil headers storage")
ErrNilHeadersStorage signals that a nil header storage has been provided
var ErrNilKeyGen = errors.New("nil key generator")
ErrNilKeyGen signals that an operation has been attempted to or with a nil single sign key generator
var ErrNilMarshalizer = errors.New("nil Marshalizer")
ErrNilMarshalizer signals that an operation has been attempted to or with a nil Marshalizer implementation
var ErrNilMessage = errors.New("nil message")
ErrNilMessage signals that a nil message has been received
var ErrNilMessenger = errors.New("nil Messenger")
ErrNilMessenger signals that a nil Messenger object was provided
var ErrNilMetaBlockHeader = errors.New("nil metablock header")
ErrNilMetaBlockHeader signals that an operation has been attempted to or with a nil metablock
var ErrNilMetaBlockPool = errors.New("nil meta block pool")
ErrNilMetaBlockPool signals that a nil meta blocks pool was used
var ErrNilMetachainHeadersDataPool = errors.New("nil metachain headers data pool")
ErrNilMetachainHeadersDataPool signals that a nil metachain header pool has been provided
var ErrNilMetachainHeadersNoncesDataPool = errors.New("nil metachain headers nonces cache")
ErrNilMetachainHeadersNoncesDataPool signals a nil metachain header - nonce cache
var ErrNilMetachainHeadersStorage = errors.New("nil metachain headers storage")
ErrNilMetachainHeadersStorage signals that a nil metachain header storage has been provided
var ErrNilMiniBlockHeaders = errors.New("nil mini block headers")
ErrNilMiniBlockHeaders signals that an operation has been attempted with a nil mini-block
var ErrNilMiniBlockPool = errors.New("nil mini block pool")
ErrNilMiniBlockPool signals that a nil mini blocks pool was used
var ErrNilMiniBlocks = errors.New("nil mini blocks")
ErrNilMiniBlocks signals that an operation has been attempted with a nil mini-block
var ErrNilMiniBlocksRequestHandler = errors.New("nil request miniblock handler")
ErrNilMiniBlocksRequestHandler signals that a nil mini block request handler func was provided
var ErrNilMultiSigVerifier = errors.New("nil multi-signature verifier")
ErrNilMultiSigVerifier signals that a nil multi-signature verifier is used
var ErrNilPeerBlockBody = errors.New("nil block body")
ErrNilPeerBlockBody signals that an operation has been attempted to or with a nil block body
var ErrNilPoolsHolder = errors.New("nil pools holder")
ErrNilPoolsHolder signals that an operation has been attempted to or with a nil pools holder object
var ErrNilPrevRandSeed = errors.New("provided previous rand seed is nil")
ErrNilPrevRandSeed signals that a nil previous rand seed has been provided
var ErrNilPreviousBlockHash = errors.New("nil previous block header hash")
ErrNilPreviousBlockHash signals that a operation has been attempted with a nil previous block header hash
var ErrNilPubKeysBitmap = errors.New("nil public keys bitmap")
ErrNilPubKeysBitmap signals that a operation has been attempted with a nil public keys bitmap
var ErrNilPublicKey = errors.New("nil public key")
ErrNilPublicKey signals that a operation has been attempted with a nil public key
var ErrNilRandSeed = errors.New("provided rand seed is nil")
ErrNilRandSeed signals that a nil rand seed has been provided
var ErrNilRcvAddr = errors.New("nil receiver address")
ErrNilRcvAddr signals that an operation has been attempted to or with a nil receiver address
var ErrNilRequestHeaderHandler = errors.New("nil request header handler")
ErrNilRequestHeaderHandler signals that a nil header request handler func was provided
var ErrNilResolverContainer = errors.New("nil resolver container")
ErrNilResolverContainer signals that a nil resolver container was provided
var ErrNilResolverSender = errors.New("nil resolver sender")
ErrNilResolverSender signals that a nil resolver sender object has been provided
var ErrNilRootHash = errors.New("root hash is nil")
ErrNilRootHash signals that an operation has been attempted with a nil root hash
var ErrNilRounder = errors.New("nil Rounder")
ErrNilRounder signals that an operation has been attempted to or with a nil Rounder implementation
var ErrNilShardCoordinator = errors.New("nil shard coordinator")
ErrNilShardCoordinator signals that an operation has been attempted to or with a nil shard coordinator
var ErrNilSignature = errors.New("nil signature")
ErrNilSignature signals that a operation has been attempted with a nil signature
var ErrNilSingleSigner = errors.New("nil single signer")
ErrNilSingleSigner signals that a nil single signer is used
var ErrNilSndAddr = errors.New("nil sender address")
ErrNilSndAddr signals that an operation has been attempted to or with a nil sender address
var ErrNilStorage = errors.New("nil storage")
ErrNilStorage signals that a nil storage has been provided
var ErrNilStore = errors.New("nil data storage service")
ErrNilStore signals that the provided storage service is nil
var ErrNilTransaction = errors.New("nil transaction")
ErrNilTransaction signals that an operation has been attempted to or with a nil transaction
var ErrNilTransactionHandler = errors.New("nil request transaction handler")
ErrNilTransactionHandler signals that a nil transaction handler func was provided
var ErrNilTransactionPool = errors.New("nil transaction pool")
ErrNilTransactionPool signals that a nil transaction pool was used
var ErrNilTxBlockBody = errors.New("nil tx block body")
ErrNilTxBlockBody signals that an operation has been attempted to or with a nil tx block body
var ErrNilTxDataPool = errors.New("nil transaction data pool")
ErrNilTxDataPool signals that a nil transaction pool has been provided
var ErrNilTxHash = errors.New("nil transaction hash")
ErrNilTxHash signals that an operation has been attempted with a nil hash
var ErrNilTxHashes = errors.New("nil transaction hashes")
ErrNilTxHashes signals that an operation has been atempted with nil transaction hashes
var ErrNilTxProcessor = errors.New("nil transactions processor")
ErrNilTxProcessor signals that a nil transactions processor was used
var ErrNilTxStorage = errors.New("nil transaction storage")
ErrNilTxStorage signals that a nil transaction storage has been provided
var ErrNilValue = errors.New("nil value")
ErrNilValue signals the value is nil
var ErrNoTransactionInMessage = errors.New("no transaction found in received message")
ErrNoTransactionInMessage signals that no transaction was found after parsing received p2p message
var ErrNoVM = errors.New("no VM (hook not set)")
ErrNoVM signals that no SCHandler has been set
var ErrNotImplementedBlockProcessingType = errors.New("not implemented block processing type")
ErrNotImplementedBlockProcessingType signals that a not supported block body type was found in header
var ErrRandSeedMismatch = errors.New("random seeds do not match")
ErrRandSeedMismatch signals that random seeds are not equal
var ErrRollbackFromGenesis = errors.New("roll back from genesis is not supported")
ErrRollbackFromGenesis signals that a rollback from genesis is called
var ErrRootStateMissmatch = errors.New("root state does not match")
ErrRootStateMissmatch signals that persist some data was not done with success
var ErrShardIdMissmatch = errors.New("shard ID missmatch")
ErrShardIdMissmatch signals shard ID does not match expectations
var ErrTimeIsOut = errors.New("time is out")
ErrTimeIsOut signals that time is out
var ErrUnmarshalWithoutSuccess = errors.New("unmarshal without success")
ErrUnmarshalWithoutSuccess signals that unmarshal some data was not done with success
var ErrWrongNonceInBlock = errors.New("wrong nonce in block")
ErrWrongNonceInBlock signals the nonce in block is different than expected nonce
var ErrWrongTypeAssertion = errors.New("wrong type assertion")
ErrWrongTypeAssertion signals that an type assertion failed
var ErrWrongTypeInContainer = errors.New("wrong type of object inside container")
ErrWrongTypeInContainer signals that a wrong type of object was found in container
Functions ¶
func GetShardHeader ¶
func GetShardHeader( hash []byte, cacher storage.Cacher, marshalizer marshal.Marshalizer, storageService dataRetriever.StorageService, ) (*block.Header, error)
GetShardHeader gets the header, which is associated with the given hash, from pool or storage
func GetShardHeaderFromPool ¶
GetShardHeaderFromPool gets the header, which is associated with the given hash, from pool
func GetShardHeaderFromStorage ¶
func GetShardHeaderFromStorage( hash []byte, marshalizer marshal.Marshalizer, storageService dataRetriever.StorageService, ) (*block.Header, error)
GetShardHeaderFromStorage gets the header, which is associated with the given hash, from storage
func ShardCacherIdentifier ¶
ShardCacherIdentifier generates a string identifier between 2 shards
Types ¶
type BlockHeaderState ¶
type BlockHeaderState int
BlockHeaderState specifies which is the state of the block header received
const ( // BHReceived defines ID of a received block header BHReceived BlockHeaderState = iota // BHProcessed defines ID of a processed block header BHProcessed // BHProposed defines ID of a proposed block header BHProposed )
type BlockProcessor ¶
type BlockProcessor interface { ProcessBlock(blockChain data.ChainHandler, header data.HeaderHandler, body data.BodyHandler, haveTime func() time.Duration) error CommitBlock(blockChain data.ChainHandler, header data.HeaderHandler, body data.BodyHandler) error RevertAccountState() CreateBlockBody(round int32, haveTime func() bool) (data.BodyHandler, error) RestoreBlockIntoPools(header data.HeaderHandler, body data.BodyHandler) error CreateBlockHeader(body data.BodyHandler, round int32, haveTime func() bool) (data.HeaderHandler, error) MarshalizedDataToBroadcast(header data.HeaderHandler, body data.BodyHandler) (map[uint32][]byte, map[uint32][][]byte, error) DecodeBlockBody(dta []byte) data.BodyHandler DecodeBlockHeader(dta []byte) data.HeaderHandler }
BlockProcessor is the main interface for block execution engine
type BlocksTracker ¶
type BlocksTracker interface { UnnotarisedBlocks() []data.HeaderHandler RemoveNotarisedBlocks(headerHandler data.HeaderHandler) error AddBlock(headerHandler data.HeaderHandler) SetBlockBroadcastRound(nonce uint64, round int32) BlockBroadcastRound(nonce uint64) int32 }
BlocksTracker defines the functionality to track all the notarised blocks
type Bootstrapper ¶
type Bootstrapper interface { AddSyncStateListener(func(bool)) ShouldSync() bool StopSync() StartSync() }
Bootstrapper is an interface that defines the behaviour of a struct that is able to synchronize the node
type Checker ¶
type Checker interface { // IntegrityAndValidity does both validity and integrity checks on the data structure IntegrityAndValidity(coordinator sharding.Coordinator) error // Integrity checks only the integrity of the data Integrity(coordinator sharding.Coordinator) error }
Checker provides functionality to checks the integrity and validity of a data structure
type ChronologyValidator ¶
type ChronologyValidator interface {
ValidateReceivedBlock(shardID uint32, epoch uint32, nonce uint64, round uint32) error
}
ChronologyValidator defines the functionality needed to validate a received header block (shard or metachain) from chronology point of view
type DataPacker ¶
DataPacker can split a large slice of byte slices in smaller packets
type ForkDetector ¶
type ForkDetector interface { AddHeader(header data.HeaderHandler, hash []byte, state BlockHeaderState) error RemoveHeaders(nonce uint64, hash []byte) CheckFork() (bool, uint64) GetHighestFinalBlockNonce() uint64 ProbableHighestNonce() uint64 }
ForkDetector is an interface that defines the behaviour of a struct that is able to detect forks
type HashAccesser ¶
HashAccesser interface provides functionality over hashable objects
type InterceptedBlockBody ¶
type InterceptedBlockBody interface { Checker HashAccesser GetUnderlyingObject() interface{} }
InterceptedBlockBody interface provides functionality over intercepted blocks
type Interceptor ¶
type Interceptor interface {
ProcessReceivedMessage(message p2p.MessageP2P) error
}
Interceptor defines what a data interceptor should do It should also adhere to the p2p.MessageProcessor interface so it can wire to a p2p.Messenger
type InterceptorsContainer ¶
type InterceptorsContainer interface { Get(key string) (Interceptor, error) Add(key string, val Interceptor) error AddMultiple(keys []string, interceptors []Interceptor) error Replace(key string, val Interceptor) error Remove(key string) Len() int }
InterceptorsContainer defines an interceptors holder data type with basic functionality
type InterceptorsContainerFactory ¶
type InterceptorsContainerFactory interface {
Create() (InterceptorsContainer, error)
}
InterceptorsContainerFactory defines the functionality to create an interceptors container
type MessageHandler ¶
type MessageHandler interface { ConnectedPeersOnTopic(topic string) []p2p.PeerID SendToConnectedPeer(topic string, buff []byte, peerID p2p.PeerID) error }
MessageHandler defines the functionality needed by structs to send data to other peers
type RequiredDataPool ¶
type RequiredDataPool struct {
// contains filtered or unexported fields
}
RequiredDataPool represents a structure that can hold a list of required data. Any time one of the expected hash value is received, the associated bit in the receivedBitmap property is set to 1. All of the data is considered received when the ones count of the received bitmap is equal to the expected data length
func (*RequiredDataPool) ExpectedData ¶
func (rh *RequiredDataPool) ExpectedData() [][]byte
ExpectedData returns the RequiredDataPool's expected data
func (*RequiredDataPool) ReceivedAll ¶
func (rh *RequiredDataPool) ReceivedAll() bool
ReceivedAll will return true if the count of ones in the bitmap is greater or equal to the expected data length
func (*RequiredDataPool) SetHashes ¶
func (rh *RequiredDataPool) SetHashes(hashes [][]byte)
SetHashes sets the expected data to the passed hashes parameter. The bitmap is also reset and adapted to the length of the new expected data
func (*RequiredDataPool) SetReceivedHash ¶
func (rh *RequiredDataPool) SetReceivedHash(hash []byte)
SetReceivedHash finds the hash in the expected values and sets the appropriate bit to 1. Nothing will happen if the hash is not actually expected
type SigVerifier ¶
type SigVerifier interface {
VerifySig() error
}
SigVerifier provides functionality to verify a signature of a signed data structure that holds also the verifying parameters
type SignedDataValidator ¶
type SignedDataValidator interface { SigVerifier Checker }
SignedDataValidator provides functionality to check the validity and signature of a data structure
type TopicHandler ¶
type TopicHandler interface { HasTopic(name string) bool CreateTopic(name string, createChannelForTopic bool) error RegisterMessageProcessor(topic string, handler p2p.MessageProcessor) error }
TopicHandler defines the functionality needed by structs to manage topics and message processors
type TopicMessageHandler ¶
type TopicMessageHandler interface { MessageHandler TopicHandler }
TopicMessageHandler defines the functionality needed by structs to manage topics, message processors and to send data to other peers
type TransactionProcessor ¶
type TransactionProcessor interface { SCHandler() func(accountsAdapter state.AccountsAdapter, transaction *transaction.Transaction) error SetSCHandler(func(accountsAdapter state.AccountsAdapter, transaction *transaction.Transaction) error) ProcessTransaction(transaction *transaction.Transaction, round int32) error }
TransactionProcessor is the main interface for transaction execution engine