Documentation ¶
Index ¶
- Constants
- Variables
- func GetConsensusTopicID(shardCoordinator sharding.Coordinator) string
- func NewConsensusMessageValidator(args *ArgsConsensusMessageValidator) (*consensusMessageValidator, error)
- func NewRoundConsensus(eligibleNodes map[string]struct{}, consensusGroupSize int, selfId string) *roundConsensus
- func NewRoundState() *roundState
- func NewRoundStatus() *roundStatus
- func NewRoundThreshold() *roundThreshold
- func NewScheduledProcessorWrapper(args ScheduledProcessorWrapperArgs) (*scheduledProcessorWrapper, error)
- func ValidateConsensusCore(container ConsensusCoreHandler) error
- type ArgsConsensusMessageValidator
- type ConsensusCore
- func (cc *ConsensusCore) BlockProcessor() process.BlockProcessor
- func (cc *ConsensusCore) Blockchain() data.ChainHandler
- func (cc *ConsensusCore) BootStrapper() process.Bootstrapper
- func (cc *ConsensusCore) BroadcastMessenger() consensus.BroadcastMessenger
- func (cc *ConsensusCore) Chronology() consensus.ChronologyHandler
- func (cc *ConsensusCore) EpochStartRegistrationHandler() epochStart.RegistrationHandler
- func (cc *ConsensusCore) FallbackHeaderValidator() consensus.FallbackHeaderValidator
- func (cc *ConsensusCore) GetAntiFloodHandler() consensus.P2PAntifloodHandler
- func (cc *ConsensusCore) Hasher() hashing.Hasher
- func (cc *ConsensusCore) HeaderSigVerifier() consensus.HeaderSigVerifier
- func (cc *ConsensusCore) IsInterfaceNil() bool
- func (cc *ConsensusCore) Marshalizer() marshal.Marshalizer
- func (cc *ConsensusCore) MultiSigner() crypto.MultiSigner
- func (cc *ConsensusCore) NodeRedundancyHandler() consensus.NodeRedundancyHandler
- func (cc *ConsensusCore) NodesCoordinator() nodesCoordinator.NodesCoordinator
- func (cc *ConsensusCore) PeerHonestyHandler() consensus.PeerHonestyHandler
- func (cc *ConsensusCore) PrivateKey() crypto.PrivateKey
- func (cc *ConsensusCore) RoundHandler() consensus.RoundHandler
- func (cc *ConsensusCore) ScheduledProcessor() consensus.ScheduledProcessor
- func (cc *ConsensusCore) ShardCoordinator() sharding.Coordinator
- func (cc *ConsensusCore) SingleSigner() crypto.SingleSigner
- func (cc *ConsensusCore) SyncTimer() ntp.SyncTimer
- type ConsensusCoreArgs
- type ConsensusCoreHandler
- type ConsensusDataIndexer
- type ConsensusService
- type ConsensusState
- func (cns *ConsensusState) AddReceivedHeader(headerHandler data.HeaderHandler)
- func (cns *ConsensusState) CanDoSubroundJob(currentSubroundId int) bool
- func (cns *ConsensusState) CanProcessReceivedMessage(cnsDta *consensus.Message, currentRoundIndex int64, currentSubroundId int) bool
- func (rcns ConsensusState) ComputeSize(subroundId int) int
- func (rcns ConsensusState) ConsensusGroup() []string
- func (rcns ConsensusState) ConsensusGroupIndex(pubKey string) (int, error)
- func (rcns ConsensusState) ConsensusGroupSize() int
- func (rthr ConsensusState) FallbackThreshold(subroundId int) int
- func (cns *ConsensusState) GenerateBitmap(subroundId int) []byte
- func (cns *ConsensusState) GetData() []byte
- func (cns *ConsensusState) GetLeader() (string, error)
- func (cns *ConsensusState) GetNextConsensusGroup(randomSource []byte, round uint64, shardId uint32, ...) ([]string, error)
- func (cns *ConsensusState) GetReceivedHeaders() []data.HeaderHandler
- func (cns *ConsensusState) IsBlockBodyAlreadyReceived() bool
- func (cns *ConsensusState) IsConsensusDataEqual(data []byte) bool
- func (cns *ConsensusState) IsConsensusDataSet() bool
- func (cns *ConsensusState) IsHeaderAlreadyReceived() bool
- func (cns *ConsensusState) IsJobDone(node string, currentSubroundId int) bool
- func (rcns ConsensusState) IsNodeInConsensusGroup(node string) bool
- func (rcns ConsensusState) IsNodeInEligibleList(node string) bool
- func (cns *ConsensusState) IsNodeLeaderInCurrentRound(node string) bool
- func (cns *ConsensusState) IsNodeSelf(node string) bool
- func (cns *ConsensusState) IsSelfJobDone(currentSubroundId int) bool
- func (cns *ConsensusState) IsSelfLeaderInCurrentRound() bool
- func (cns *ConsensusState) IsSubroundFinished(subroundID int) bool
- func (rcns ConsensusState) JobDone(key string, subroundId int) (bool, error)
- func (cns *ConsensusState) ProcessingBlock() bool
- func (cns *ConsensusState) ResetConsensusState()
- func (rcns ConsensusState) ResetRoundState()
- func (rstatus ConsensusState) ResetRoundStatus()
- func (rcns ConsensusState) SelfConsensusGroupIndex() (int, error)
- func (rcns ConsensusState) SelfJobDone(subroundId int) (bool, error)
- func (rcns ConsensusState) SelfPubKey() string
- func (rcns ConsensusState) SetConsensusGroup(consensusGroup []string)
- func (rcns ConsensusState) SetConsensusGroupSize(consensusGroudpSize int)
- func (rcns ConsensusState) SetEligibleList(eligibleList map[string]struct{})
- func (rthr ConsensusState) SetFallbackThreshold(subroundId int, threshold int)
- func (rcns ConsensusState) SetJobDone(key string, subroundId int, value bool) error
- func (cns *ConsensusState) SetProcessingBlock(processingBlock bool)
- func (rcns ConsensusState) SetSelfJobDone(subroundId int, value bool) error
- func (rcns ConsensusState) SetSelfPubKey(selfPubKey string)
- func (rstatus ConsensusState) SetStatus(subroundId int, subroundStatus SubroundStatus)
- func (rthr ConsensusState) SetThreshold(subroundId int, threshold int)
- func (rstatus ConsensusState) Status(subroundId int) SubroundStatus
- func (rthr ConsensusState) Threshold(subroundId int) int
- type HeaderSigVerifier
- type PoolAdder
- type ScheduledProcessorWrapperArgs
- type Subround
- func (sr *Subround) AppStatusHandler() core.AppStatusHandler
- func (sr *Subround) ChainID() []byte
- func (rcns Subround) ComputeSize(subroundId int) int
- func (sr *Subround) ConsensusChannel() chan bool
- func (rcns Subround) ConsensusGroup() []string
- func (rcns Subround) ConsensusGroupIndex(pubKey string) (int, error)
- func (rcns Subround) ConsensusGroupSize() int
- func (sr *Subround) Current() int
- func (sr *Subround) CurrentPid() core.PeerID
- func (sr *Subround) DoWork(ctx context.Context, roundHandler consensus.RoundHandler) bool
- func (sr *Subround) EndTime() int64
- func (rthr Subround) FallbackThreshold(subroundId int) int
- func (sr *Subround) IsInterfaceNil() bool
- func (rcns Subround) IsNodeInConsensusGroup(node string) bool
- func (rcns Subround) IsNodeInEligibleList(node string) bool
- func (rcns Subround) JobDone(key string, subroundId int) (bool, error)
- func (sr *Subround) Name() string
- func (sr *Subround) Next() int
- func (sr *Subround) Previous() int
- func (rcns Subround) ResetRoundState()
- func (rstatus Subround) ResetRoundStatus()
- func (rcns Subround) SelfConsensusGroupIndex() (int, error)
- func (rcns Subround) SelfJobDone(subroundId int) (bool, error)
- func (rcns Subround) SelfPubKey() string
- func (rcns Subround) SetConsensusGroup(consensusGroup []string)
- func (rcns Subround) SetConsensusGroupSize(consensusGroudpSize int)
- func (rcns Subround) SetEligibleList(eligibleList map[string]struct{})
- func (rthr Subround) SetFallbackThreshold(subroundId int, threshold int)
- func (rcns Subround) SetJobDone(key string, subroundId int, value bool) error
- func (rcns Subround) SetSelfJobDone(subroundId int, value bool) error
- func (rcns Subround) SetSelfPubKey(selfPubKey string)
- func (rstatus Subround) SetStatus(subroundId int, subroundStatus SubroundStatus)
- func (rthr Subround) SetThreshold(subroundId int, threshold int)
- func (sr *Subround) StartTime() int64
- func (rstatus Subround) Status(subroundId int) SubroundStatus
- func (rthr Subround) Threshold(subroundId int) int
- type SubroundStatus
- type SubroundsFactory
- type Worker
- func (wrk *Worker) AddReceivedHeaderHandler(handler func(data.HeaderHandler))
- func (wrk *Worker) AddReceivedMessageCall(messageType consensus.MessageType, ...)
- func (wrk *Worker) Close() error
- func (wrk *Worker) DisplayStatistics()
- func (wrk *Worker) ExecuteStoredMessages()
- func (wrk *Worker) Extend(subroundId int)
- func (wrk *Worker) GetConsensusStateChangedChannel() chan bool
- func (wrk *Worker) IsInterfaceNil() bool
- func (wrk *Worker) ProcessReceivedMessage(message p2p.MessageP2P, fromConnectedPeer core.PeerID) error
- func (wrk *Worker) ReceivedHeader(headerHandler data.HeaderHandler, _ []byte)
- func (wrk *Worker) RemoveAllReceivedMessagesCalls()
- func (wrk *Worker) ResetConsensusMessages()
- func (wrk *Worker) StartWorking()
- type WorkerArgs
- type WorkerHandler
Constants ¶
const LeaderPeerHonestyDecreaseFactor = -4
LeaderPeerHonestyDecreaseFactor specifies the factor with which the honesty of the leader should be decreased if it proposed a block or sent the final info, in an incorrect allocated slot/time-frame/round
const LeaderPeerHonestyIncreaseFactor = 2
LeaderPeerHonestyIncreaseFactor specifies the factor with which the honesty of the leader should be increased if it proposed a block or sent the final info, in its correct allocated slot/time-frame/round
const MaxNumOfMessageTypeAccepted = 1
MaxNumOfMessageTypeAccepted represents the maximum number of the same message type accepted in one round to be received from the same public key
const MaxThresholdPercent = 95
MaxThresholdPercent specifies the max allocated time percent for doing Job as a percentage of the total time of one round
const ValidatorPeerHonestyDecreaseFactor = -2
ValidatorPeerHonestyDecreaseFactor specifies the factor with which the honesty of the validator should be decreased if it sent the signature, in an incorrect allocated slot/time-frame/round
const ValidatorPeerHonestyIncreaseFactor = 1
ValidatorPeerHonestyIncreaseFactor specifies the factor with which the honesty of the validator should be increased if it sent the signature, in its correct allocated slot/time-frame/round
Variables ¶
var ErrEmptyConsensusGroup = errors.New("consensusGroup is empty")
ErrEmptyConsensusGroup is raised when an operation is attempted with an empty consensus group
var ErrInvalidBodySize = errors.New("invalid body size")
ErrInvalidBodySize signals that an invalid body size has been received from consensus topic
var ErrInvalidCacheSize = errors.New("invalid cache size")
ErrInvalidCacheSize signals an invalid size provided for cache
var ErrInvalidChainID = errors.New("invalid chain ID in consensus")
ErrInvalidChainID signals that an invalid chain ID has been provided
var ErrInvalidHeader = errors.New("header is invalid")
ErrInvalidHeader is raised when header is invalid
var ErrInvalidHeaderHashSize = errors.New("invalid header hash size")
ErrInvalidHeaderHashSize signals that an invalid header hash size has been received from consensus topic
var ErrInvalidHeaderSize = errors.New("invalid header size")
ErrInvalidHeaderSize signals that an invalid header size has been received from consensus topic
var ErrInvalidKey = errors.New("map key is invalid")
ErrInvalidKey is raised when an invalid key is used with a map
var ErrInvalidMessage = errors.New("invalid message")
ErrInvalidMessage signals that an invalid message has been received from consensus topic
var ErrInvalidMessageType = errors.New("invalid message type")
ErrInvalidMessageType signals that an invalid message type has been received from consensus topic
var ErrInvalidMetaHeader = errors.New("meta header is invalid")
ErrInvalidMetaHeader is raised when an invalid meta header was provided
var ErrInvalidPublicKeyBitmapSize = errors.New("invalid public key bitmap size")
ErrInvalidPublicKeyBitmapSize signals that an invalid public key bitmap size has been received from consensus topic
var ErrInvalidPublicKeySize = errors.New("invalid public key size")
ErrInvalidPublicKeySize signals that an invalid public key size has been received from consensus topic
var ErrInvalidSignature = errors.New("signature is invalid")
ErrInvalidSignature is raised when signature is invalid
var ErrInvalidSignatureSize = errors.New("invalid signature size")
ErrInvalidSignatureSize signals that an invalid signature size has been received from consensus topic
var ErrMessageForFutureRound = errors.New("message is for future round")
ErrMessageForFutureRound is raised when message is for future round
var ErrMessageForPastRound = errors.New("message is for past round")
ErrMessageForPastRound is raised when message is for past round
var ErrMessageFromItself = errors.New("message is from itself")
ErrMessageFromItself is raised when a message from itself is received
var ErrMessageTypeLimitReached = errors.New("consensus message type limit has been reached")
ErrMessageTypeLimitReached signals that a consensus message type limit has been reached for a public key
var ErrNilAlarmScheduler = errors.New("alarm scheduler is nil")
ErrNilAlarmScheduler is raised when a valid alarm scheduler is expected but nil is provided
var ErrNilAntifloodHandler = errors.New("nil antiflood handler")
ErrNilAntifloodHandler signals that a nil antiflood handler has been provided
var ErrNilAppStatusHandler = errors.New("nil AppStatusHandler")
ErrNilAppStatusHandler defines the error for setting a nil AppStatusHandler
var ErrNilBlockChain = errors.New("blockchain is nil")
ErrNilBlockChain is raised when a valid blockchain is expected but nil used
var ErrNilBlockProcessor = errors.New("block processor is nil")
ErrNilBlockProcessor is raised when a valid block processor is expected but nil used
var ErrNilBlsPrivateKey = errors.New("BLS private key should not be nil")
ErrNilBlsPrivateKey is raised when the bls private key is nil
var ErrNilBlsSingleSigner = errors.New("BLS single signer should not be nil")
ErrNilBlsSingleSigner is raised when a message from itself is received
var ErrNilBody = errors.New("body is nil")
ErrNilBody is raised when an expected body is nil
var ErrNilBootstrapper = errors.New("bootstrapper is nil")
ErrNilBootstrapper is raised when a valid block processor is expected but nil used
var ErrNilBroadcastMessenger = errors.New("broadcast messenger is nil")
ErrNilBroadcastMessenger is raised when a valid broadcast messenger is expected but nil used
var ErrNilChannel = errors.New("channel is nil")
ErrNilChannel is raised when a valid channel is expected but nil used
var ErrNilChronologyHandler = errors.New("chronology handler is nil")
ErrNilChronologyHandler is raised when a valid chronology handler is expected but nil used
var ErrNilConsensusCore = errors.New("consensus core is nil")
ErrNilConsensusCore is raised when a valid ConsensusCore is expected but nil used
var ErrNilConsensusGroup = errors.New("consensusGroup is null")
ErrNilConsensusGroup is raised when an operation is attempted with a nil consensus group
var ErrNilConsensusService = errors.New("consensus service is nil")
ErrNilConsensusService is raised when a valid ConsensusService is expected but nil used
var ErrNilConsensusState = errors.New("consensus state is nil")
ErrNilConsensusState is raised when a valid consensus is expected but nil used
var ErrNilDataToProcess = errors.New("nil data to process")
ErrNilDataToProcess signals that nil data was provided
var ErrNilExecuteStoredMessages = errors.New("executeStoredMessages is nil")
ErrNilExecuteStoredMessages is raised when a valid executeStoredMessages function is expected but nil used
var ErrNilFallbackHeaderValidator = errors.New("nil fallback header validator")
ErrNilFallbackHeaderValidator signals that a nil fallback header validator has been provided
var ErrNilForkDetector = errors.New("fork detector is nil")
ErrNilForkDetector is raised when a valid fork detector is expected but nil used
var ErrNilHasher = errors.New("hasher is nil")
ErrNilHasher is raised when a valid hasher is expected but nil used
var ErrNilHeader = errors.New("header is nil")
ErrNilHeader is raised when an expected header is nil
var ErrNilHeaderHash = errors.New("header hash is nil")
ErrNilHeaderHash is raised when a nil header hash is provided
var ErrNilHeaderIntegrityVerifier = errors.New("nil header integrity verifier")
ErrNilHeaderIntegrityVerifier signals that a nil header integrity verifier has been provided
var ErrNilHeaderSigVerifier = errors.New("nil header sig verifier")
ErrNilHeaderSigVerifier signals that a nil header sig verifier has been provided
var ErrNilHeadersSubscriber = errors.New("headers subscriber is nil")
ErrNilHeadersSubscriber is raised when a valid headers subscriber is expected but nil is provided
var ErrNilInterceptorsContainer = errors.New("interceptor container is nil")
ErrNilInterceptorsContainer is raised when a nil interceptor container is provided
var ErrNilMarshalizer = errors.New("marshalizer is nil")
ErrNilMarshalizer is raised when a valid marshalizer is expected but nil used
var ErrNilMessage = errors.New("nil message")
ErrNilMessage signals that a nil message has been received
var ErrNilMessenger = errors.New("messenger is nil")
ErrNilMessenger is raised when a valid messenger is expected but nil used
var ErrNilMetaHeader = errors.New("meta header is nil")
ErrNilMetaHeader is raised when an expected meta header is nil
var ErrNilMultiSigner = errors.New("multiSigner is nil")
ErrNilMultiSigner is raised when a valid multiSigner is expected but nil used
var ErrNilNetworkShardingCollector = errors.New("nil network sharding collector")
ErrNilNetworkShardingCollector defines the error for setting a nil network sharding collector
var ErrNilNodeRedundancyHandler = errors.New("nil node redundancy handler")
ErrNilNodeRedundancyHandler signals that provided node redundancy handler is nil
var ErrNilNodesCoordinator = errors.New("validator group selector is nil")
ErrNilNodesCoordinator is raised when a valid validator group selector is expected but nil used
var ErrNilParameter = errors.New("parameter is nil")
ErrNilParameter is raised when a nil parameter is provided
var ErrNilPeerHonestyHandler = errors.New("nil peer honesty handler")
ErrNilPeerHonestyHandler signals that a nil peer honesty handler has been provided
var ErrNilPeerSignatureHandler = errors.New("trying to set nil peerSignatureHandler")
ErrNilPeerSignatureHandler signals that a nil peerSignatureHandler object has been provided
var ErrNilPoolAdder = errors.New("nil pool adder")
ErrNilPoolAdder signals that a nil pool adder has been provided
var ErrNilPrivateKey = errors.New("private key is nil")
ErrNilPrivateKey is raised when a valid private key was expected but nil was used
var ErrNilRoundHandler = errors.New("roundHandler is nil")
ErrNilRoundHandler is raised when a valid roundHandler is expected but nil used
var ErrNilRoundState = errors.New("round state is nil")
ErrNilRoundState is raised when a valid round state is expected but nil used
var ErrNilScheduledProcessor = errors.New("nil scheduled processor")
ErrNilScheduledProcessor signals that the provided scheduled processor is nil
var ErrNilShardCoordinator = errors.New("shard coordinator is nil")
ErrNilShardCoordinator is raised when a valid shard coordinator is expected but nil used
var ErrNilSignature = errors.New("signature is nil")
ErrNilSignature is raised when a valid signature was expected but nil was used
var ErrNilSubround = errors.New("subround is nil")
ErrNilSubround is raised when a valid subround is expected but nil used
var ErrNilSyncTimer = errors.New("sync timer is nil")
ErrNilSyncTimer is raised when a valid sync timer is expected but nil used
var ErrNilWorker = errors.New("worker is nil")
ErrNilWorker is raised when a valid Worker is expected but nil used
var ErrNilWorkerArgs = errors.New("worker args is nil")
ErrNilWorkerArgs signals that nil a workerArgs has been provided
var ErrNodeIsNotInEligibleList = errors.New("node is not in eligible list")
ErrNodeIsNotInEligibleList is raised when a node is not in eligible list
var ErrNotFoundInConsensus = errors.New("self not found in consensus group")
ErrNotFoundInConsensus is raised when self expected in consensus group but not found
var ErrOriginatorMismatch = errors.New("consensus message originator mismatch")
ErrOriginatorMismatch signals that an original consensus message has been re-broadcast manually by another peer
var ErrRoundCanceled = errors.New("round is canceled")
ErrRoundCanceled is raised when round is canceled
Functions ¶
func GetConsensusTopicID ¶
func GetConsensusTopicID(shardCoordinator sharding.Coordinator) string
GetConsensusTopicID will construct and return the topic ID based on shard coordinator
func NewConsensusMessageValidator ¶
func NewConsensusMessageValidator(args *ArgsConsensusMessageValidator) (*consensusMessageValidator, error)
NewConsensusMessageValidator creates a new consensusMessageValidator object
func NewRoundConsensus ¶
func NewRoundConsensus( eligibleNodes map[string]struct{}, consensusGroupSize int, selfId string, ) *roundConsensus
NewRoundConsensus creates a new roundConsensus object
func NewRoundStatus ¶
func NewRoundStatus() *roundStatus
NewRoundStatus creates a new roundStatus object
func NewRoundThreshold ¶
func NewRoundThreshold() *roundThreshold
NewRoundThreshold creates a new roundThreshold object
func NewScheduledProcessorWrapper ¶
func NewScheduledProcessorWrapper(args ScheduledProcessorWrapperArgs) (*scheduledProcessorWrapper, error)
NewScheduledProcessorWrapper creates a new processor for scheduled transactions
func ValidateConsensusCore ¶
func ValidateConsensusCore(container ConsensusCoreHandler) error
ValidateConsensusCore checks for nil all the container objects
Types ¶
type ArgsConsensusMessageValidator ¶
type ArgsConsensusMessageValidator struct { ConsensusState *ConsensusState ConsensusService ConsensusService PeerSignatureHandler crypto.PeerSignatureHandler SignatureSize int PublicKeySize int HasherSize int ChainID []byte }
ArgsConsensusMessageValidator holds the consensus message validator arguments
type ConsensusCore ¶
type ConsensusCore struct {
// contains filtered or unexported fields
}
ConsensusCore implements ConsensusCoreHandler and provides access to common functionality
for the rest of the consensus structures
func NewConsensusCore ¶
func NewConsensusCore( args *ConsensusCoreArgs, ) (*ConsensusCore, error)
NewConsensusCore creates a new ConsensusCore instance
func (*ConsensusCore) BlockProcessor ¶
func (cc *ConsensusCore) BlockProcessor() process.BlockProcessor
BlockProcessor gets the BlockProcessor stored in the ConsensusCore
func (*ConsensusCore) Blockchain ¶
func (cc *ConsensusCore) Blockchain() data.ChainHandler
Blockchain gets the ChainHandler stored in the ConsensusCore
func (*ConsensusCore) BootStrapper ¶
func (cc *ConsensusCore) BootStrapper() process.Bootstrapper
BootStrapper gets the Bootstrapper stored in the ConsensusCore
func (*ConsensusCore) BroadcastMessenger ¶
func (cc *ConsensusCore) BroadcastMessenger() consensus.BroadcastMessenger
BroadcastMessenger gets the BroadcastMessenger stored in the ConsensusCore
func (*ConsensusCore) Chronology ¶
func (cc *ConsensusCore) Chronology() consensus.ChronologyHandler
Chronology gets the ChronologyHandler stored in the ConsensusCore
func (*ConsensusCore) EpochStartRegistrationHandler ¶
func (cc *ConsensusCore) EpochStartRegistrationHandler() epochStart.RegistrationHandler
EpochStartRegistrationHandler returns the epoch start registration handler
func (*ConsensusCore) FallbackHeaderValidator ¶
func (cc *ConsensusCore) FallbackHeaderValidator() consensus.FallbackHeaderValidator
FallbackHeaderValidator will return the fallback header validator which will be used in subrounds
func (*ConsensusCore) GetAntiFloodHandler ¶
func (cc *ConsensusCore) GetAntiFloodHandler() consensus.P2PAntifloodHandler
GetAntiFloodHandler will return the antiflood handler which will be used in subrounds
func (*ConsensusCore) Hasher ¶
func (cc *ConsensusCore) Hasher() hashing.Hasher
Hasher gets the Hasher stored in the ConsensusCore
func (*ConsensusCore) HeaderSigVerifier ¶
func (cc *ConsensusCore) HeaderSigVerifier() consensus.HeaderSigVerifier
HeaderSigVerifier returns the sig verifier handler which will be used in subrounds
func (*ConsensusCore) IsInterfaceNil ¶
func (cc *ConsensusCore) IsInterfaceNil() bool
IsInterfaceNil returns true if there is no value under the interface
func (*ConsensusCore) Marshalizer ¶
func (cc *ConsensusCore) Marshalizer() marshal.Marshalizer
Marshalizer gets the Marshalizer stored in the ConsensusCore
func (*ConsensusCore) MultiSigner ¶
func (cc *ConsensusCore) MultiSigner() crypto.MultiSigner
MultiSigner gets the MultiSigner stored in the ConsensusCore
func (*ConsensusCore) NodeRedundancyHandler ¶
func (cc *ConsensusCore) NodeRedundancyHandler() consensus.NodeRedundancyHandler
NodeRedundancyHandler will return the node redundancy handler which will be used in subrounds
func (*ConsensusCore) NodesCoordinator ¶
func (cc *ConsensusCore) NodesCoordinator() nodesCoordinator.NodesCoordinator
NodesCoordinator gets the NodesCoordinator stored in the ConsensusCore
func (*ConsensusCore) PeerHonestyHandler ¶
func (cc *ConsensusCore) PeerHonestyHandler() consensus.PeerHonestyHandler
PeerHonestyHandler will return the peer honesty handler which will be used in subrounds
func (*ConsensusCore) PrivateKey ¶
func (cc *ConsensusCore) PrivateKey() crypto.PrivateKey
PrivateKey returns the BLS private key stored in the ConsensusStore
func (*ConsensusCore) RoundHandler ¶
func (cc *ConsensusCore) RoundHandler() consensus.RoundHandler
RoundHandler gets the RoundHandler stored in the ConsensusCore
func (*ConsensusCore) ScheduledProcessor ¶
func (cc *ConsensusCore) ScheduledProcessor() consensus.ScheduledProcessor
ScheduledProcessor will return the scheduled processor
func (*ConsensusCore) ShardCoordinator ¶
func (cc *ConsensusCore) ShardCoordinator() sharding.Coordinator
ShardCoordinator gets the ShardCoordinator stored in the ConsensusCore
func (*ConsensusCore) SingleSigner ¶
func (cc *ConsensusCore) SingleSigner() crypto.SingleSigner
SingleSigner returns the bls single signer stored in the ConsensusStore
func (*ConsensusCore) SyncTimer ¶
func (cc *ConsensusCore) SyncTimer() ntp.SyncTimer
SyncTimer gets the SyncTimer stored in the ConsensusCore
type ConsensusCoreArgs ¶
type ConsensusCoreArgs struct { BlockChain data.ChainHandler BlockProcessor process.BlockProcessor Bootstrapper process.Bootstrapper BroadcastMessenger consensus.BroadcastMessenger ChronologyHandler consensus.ChronologyHandler Hasher hashing.Hasher Marshalizer marshal.Marshalizer BlsPrivateKey crypto.PrivateKey BlsSingleSigner crypto.SingleSigner MultiSigner crypto.MultiSigner RoundHandler consensus.RoundHandler ShardCoordinator sharding.Coordinator NodesCoordinator nodesCoordinator.NodesCoordinator SyncTimer ntp.SyncTimer EpochStartRegistrationHandler epochStart.RegistrationHandler AntifloodHandler consensus.P2PAntifloodHandler PeerHonestyHandler consensus.PeerHonestyHandler HeaderSigVerifier consensus.HeaderSigVerifier FallbackHeaderValidator consensus.FallbackHeaderValidator NodeRedundancyHandler consensus.NodeRedundancyHandler ScheduledProcessor consensus.ScheduledProcessor }
ConsensusCoreArgs store all arguments that are needed to create a ConsensusCore object
type ConsensusCoreHandler ¶
type ConsensusCoreHandler interface { // Blockchain gets the ChainHandler stored in the ConsensusCore Blockchain() data.ChainHandler // BlockProcessor gets the BlockProcessor stored in the ConsensusCore BlockProcessor() process.BlockProcessor // BootStrapper gets the Bootstrapper stored in the ConsensusCore BootStrapper() process.Bootstrapper // BroadcastMessenger gets the BroadcastMessenger stored in ConsensusCore BroadcastMessenger() consensus.BroadcastMessenger // Chronology gets the ChronologyHandler stored in the ConsensusCore Chronology() consensus.ChronologyHandler // GetAntiFloodHandler returns the antiflood handler which will be used in subrounds GetAntiFloodHandler() consensus.P2PAntifloodHandler // Hasher gets the Hasher stored in the ConsensusCore Hasher() hashing.Hasher // Marshalizer gets the Marshalizer stored in the ConsensusCore Marshalizer() marshal.Marshalizer // MultiSigner gets the MultiSigner stored in the ConsensusCore MultiSigner() crypto.MultiSigner // RoundHandler gets the RoundHandler stored in the ConsensusCore RoundHandler() consensus.RoundHandler // ShardCoordinator gets the ShardCoordinator stored in the ConsensusCore ShardCoordinator() sharding.Coordinator // SyncTimer gets the SyncTimer stored in the ConsensusCore SyncTimer() ntp.SyncTimer // NodesCoordinator gets the NodesCoordinator stored in the ConsensusCore NodesCoordinator() nodesCoordinator.NodesCoordinator // EpochStartRegistrationHandler gets the RegistrationHandler stored in the ConsensusCore EpochStartRegistrationHandler() epochStart.RegistrationHandler // PrivateKey returns the private key stored in the ConsensusStore used for randomness and leader's signature generation PrivateKey() crypto.PrivateKey // SingleSigner returns the single signer stored in the ConsensusStore used for randomness and leader's signature generation SingleSigner() crypto.SingleSigner // PeerHonestyHandler returns the peer honesty handler which will be used in subrounds PeerHonestyHandler() consensus.PeerHonestyHandler // HeaderSigVerifier returns the sig verifier handler which will be used in subrounds HeaderSigVerifier() consensus.HeaderSigVerifier // FallbackHeaderValidator returns the fallback header validator handler which will be used in subrounds FallbackHeaderValidator() consensus.FallbackHeaderValidator // NodeRedundancyHandler returns the node redundancy handler which will be used in subrounds NodeRedundancyHandler() consensus.NodeRedundancyHandler // ScheduledProcessor returns the scheduled txs processor ScheduledProcessor() consensus.ScheduledProcessor // IsInterfaceNil returns true if there is no value under the interface IsInterfaceNil() bool }
ConsensusCoreHandler encapsulates all needed data for the Consensus
type ConsensusDataIndexer ¶
type ConsensusDataIndexer interface { SaveRoundsInfo(roundsInfos []*indexer.RoundInfo) IsInterfaceNil() bool }
ConsensusDataIndexer defines the actions that a consensus data indexer has to do
type ConsensusService ¶
type ConsensusService interface { // InitReceivedMessages initializes the MessagesType map for all messages for the current ConsensusService InitReceivedMessages() map[consensus.MessageType][]*consensus.Message // GetStringValue gets the name of the messageType GetStringValue(consensus.MessageType) string // GetSubroundName gets the subround name for the subround id provided GetSubroundName(int) string // GetMessageRange provides the MessageType range used in checks by the consensus GetMessageRange() []consensus.MessageType // CanProceed returns if the current messageType can proceed further if previous subrounds finished CanProceed(*ConsensusState, consensus.MessageType) bool // IsMessageWithBlockBodyAndHeader returns if the current messageType is about block body and header IsMessageWithBlockBodyAndHeader(consensus.MessageType) bool // IsMessageWithBlockBody returns if the current messageType is about block body IsMessageWithBlockBody(consensus.MessageType) bool // IsMessageWithBlockHeader returns if the current messageType is about block header IsMessageWithBlockHeader(consensus.MessageType) bool // IsMessageWithSignature returns if the current messageType is about signature IsMessageWithSignature(consensus.MessageType) bool // IsMessageWithFinalInfo returns if the current messageType is about header final info IsMessageWithFinalInfo(consensus.MessageType) bool // IsMessageTypeValid returns if the current messageType is valid IsMessageTypeValid(consensus.MessageType) bool // IsSubroundSignature returns if the current subround is about signature IsSubroundSignature(int) bool // IsSubroundStartRound returns if the current subround is about start round IsSubroundStartRound(int) bool // GetMaxMessagesInARoundPerPeer returns the maximum number of messages a peer can send per round GetMaxMessagesInARoundPerPeer() uint32 // IsInterfaceNil returns true if there is no value under the interface IsInterfaceNil() bool }
ConsensusService encapsulates the methods specifically for a consensus type (bls, bn) and will be used in the sposWorker
type ConsensusState ¶
type ConsensusState struct { // hold the data on which validators do the consensus (could be for example a hash of the block header // proposed by the leader) Data []byte Body data.BodyHandler Header data.HeaderHandler RoundIndex int64 RoundTimeStamp time.Time RoundCanceled bool ExtendedCalled bool WaitingAllSignaturesTimeOut bool // contains filtered or unexported fields }
ConsensusState defines the data needed by spos to do the consensus in each round
func NewConsensusState ¶
func NewConsensusState( roundConsensus *roundConsensus, roundThreshold *roundThreshold, roundStatus *roundStatus, ) *ConsensusState
NewConsensusState creates a new ConsensusState object
func (*ConsensusState) AddReceivedHeader ¶
func (cns *ConsensusState) AddReceivedHeader(headerHandler data.HeaderHandler)
AddReceivedHeader append the provided header to the inner received headers list
func (*ConsensusState) CanDoSubroundJob ¶
func (cns *ConsensusState) CanDoSubroundJob(currentSubroundId int) bool
CanDoSubroundJob method returns true if the job of the subround can be done and false otherwise
func (*ConsensusState) CanProcessReceivedMessage ¶
func (cns *ConsensusState) CanProcessReceivedMessage(cnsDta *consensus.Message, currentRoundIndex int64, currentSubroundId int) bool
CanProcessReceivedMessage method returns true if the message received can be processed and false otherwise
func (ConsensusState) ComputeSize ¶
ComputeSize method returns the number of messages received from the nodes belonging to the current jobDone group related to this subround
func (ConsensusState) ConsensusGroup ¶
func (rcns ConsensusState) ConsensusGroup() []string
ConsensusGroup returns the consensus group ID's
func (ConsensusState) ConsensusGroupIndex ¶
ConsensusGroupIndex returns the index of given public key in the current consensus group
func (ConsensusState) ConsensusGroupSize ¶
func (rcns ConsensusState) ConsensusGroupSize() int
ConsensusGroupSize returns the consensus group size
func (ConsensusState) FallbackThreshold ¶
FallbackThreshold returns the fallback threshold of agreements needed in the given subround id
func (*ConsensusState) GenerateBitmap ¶
func (cns *ConsensusState) GenerateBitmap(subroundId int) []byte
GenerateBitmap method generates a bitmap, for a given subround, in which each node will be marked with 1 if its job has been done
func (*ConsensusState) GetData ¶
func (cns *ConsensusState) GetData() []byte
GetData gets the Data of the consensusState
func (*ConsensusState) GetLeader ¶
func (cns *ConsensusState) GetLeader() (string, error)
GetLeader method gets the leader of the current round
func (*ConsensusState) GetNextConsensusGroup ¶
func (cns *ConsensusState) GetNextConsensusGroup( randomSource []byte, round uint64, shardId uint32, nodesCoordinator nodesCoordinator.NodesCoordinator, epoch uint32, ) ([]string, error)
GetNextConsensusGroup gets the new consensus group for the current round based on current eligible list and a random source for the new selection
func (*ConsensusState) GetReceivedHeaders ¶
func (cns *ConsensusState) GetReceivedHeaders() []data.HeaderHandler
GetReceivedHeaders returns the received headers list
func (*ConsensusState) IsBlockBodyAlreadyReceived ¶
func (cns *ConsensusState) IsBlockBodyAlreadyReceived() bool
IsBlockBodyAlreadyReceived method returns true if block body is already received and false otherwise
func (*ConsensusState) IsConsensusDataEqual ¶
func (cns *ConsensusState) IsConsensusDataEqual(data []byte) bool
IsConsensusDataEqual method returns true if the consensus data for the current round is the same with the given one and false otherwise
func (*ConsensusState) IsConsensusDataSet ¶
func (cns *ConsensusState) IsConsensusDataSet() bool
IsConsensusDataSet method returns true if the consensus data for the current round is set and false otherwise
func (*ConsensusState) IsHeaderAlreadyReceived ¶
func (cns *ConsensusState) IsHeaderAlreadyReceived() bool
IsHeaderAlreadyReceived method returns true if header is already received and false otherwise
func (*ConsensusState) IsJobDone ¶
func (cns *ConsensusState) IsJobDone(node string, currentSubroundId int) bool
IsJobDone method returns true if the node job for the current subround is done and false otherwise
func (ConsensusState) IsNodeInConsensusGroup ¶
IsNodeInConsensusGroup method checks if the node is part of consensus group of the current round
func (ConsensusState) IsNodeInEligibleList ¶
IsNodeInEligibleList method checks if the node is part of the eligible list
func (*ConsensusState) IsNodeLeaderInCurrentRound ¶
func (cns *ConsensusState) IsNodeLeaderInCurrentRound(node string) bool
IsNodeLeaderInCurrentRound method checks if the given node is leader in the current round
func (*ConsensusState) IsNodeSelf ¶
func (cns *ConsensusState) IsNodeSelf(node string) bool
IsNodeSelf method returns true if the message is received from itself and false otherwise
func (*ConsensusState) IsSelfJobDone ¶
func (cns *ConsensusState) IsSelfJobDone(currentSubroundId int) bool
IsSelfJobDone method returns true if self job for the current subround is done and false otherwise
func (*ConsensusState) IsSelfLeaderInCurrentRound ¶
func (cns *ConsensusState) IsSelfLeaderInCurrentRound() bool
IsSelfLeaderInCurrentRound method checks if the current node is leader in the current round
func (*ConsensusState) IsSubroundFinished ¶
func (cns *ConsensusState) IsSubroundFinished(subroundID int) bool
IsSubroundFinished method returns true if the current subround is finished and false otherwise
func (ConsensusState) JobDone ¶
JobDone returns the state of the action done, by the node represented by the key parameter, in subround given by the subroundId parameter
func (*ConsensusState) ProcessingBlock ¶
func (cns *ConsensusState) ProcessingBlock() bool
ProcessingBlock gets the state of block processing
func (*ConsensusState) ResetConsensusState ¶
func (cns *ConsensusState) ResetConsensusState()
ResetConsensusState method resets all the consensus data
func (ConsensusState) ResetRoundState ¶
func (rcns ConsensusState) ResetRoundState()
ResetRoundState method resets the state of each node from the current jobDone group, regarding to the consensus validatorRoundStates
func (ConsensusState) ResetRoundStatus ¶
func (rstatus ConsensusState) ResetRoundStatus()
ResetRoundStatus method resets the state of each subround
func (ConsensusState) SelfConsensusGroupIndex ¶
SelfConsensusGroupIndex returns the index of self public key in current consensus group
func (ConsensusState) SelfJobDone ¶
SelfJobDone returns the self state of the action done in subround given by the subroundId parameter
func (ConsensusState) SelfPubKey ¶
func (rcns ConsensusState) SelfPubKey() string
SelfPubKey returns selfPubKey ID
func (ConsensusState) SetConsensusGroup ¶
func (rcns ConsensusState) SetConsensusGroup(consensusGroup []string)
SetConsensusGroup sets the consensus group ID's
func (ConsensusState) SetConsensusGroupSize ¶
func (rcns ConsensusState) SetConsensusGroupSize(consensusGroudpSize int)
SetConsensusGroupSize sets the consensus group size
func (ConsensusState) SetEligibleList ¶
func (rcns ConsensusState) SetEligibleList(eligibleList map[string]struct{})
SetEligibleList sets the eligible list ID's
func (ConsensusState) SetFallbackThreshold ¶
SetFallbackThreshold sets the fallback threshold of agreements needed in the given subround id
func (ConsensusState) SetJobDone ¶
SetJobDone set the state of the action done, by the node represented by the key parameter, in subround given by the subroundId parameter
func (*ConsensusState) SetProcessingBlock ¶
func (cns *ConsensusState) SetProcessingBlock(processingBlock bool)
SetProcessingBlock sets the state of block processing
func (ConsensusState) SetSelfJobDone ¶
SetSelfJobDone set the self state of the action done in subround given by the subroundId parameter
func (ConsensusState) SetSelfPubKey ¶
func (rcns ConsensusState) SetSelfPubKey(selfPubKey string)
SetSelfPubKey sets selfPubKey ID
func (ConsensusState) SetStatus ¶
func (rstatus ConsensusState) SetStatus(subroundId int, subroundStatus SubroundStatus)
SetStatus sets the status of the given subround id
func (ConsensusState) SetThreshold ¶
SetThreshold sets the threshold of agreements needed in the given subround id
func (ConsensusState) Status ¶
func (rstatus ConsensusState) Status(subroundId int) SubroundStatus
Status returns the status of the given subround id
type HeaderSigVerifier ¶
type HeaderSigVerifier interface { VerifyRandSeed(header data.HeaderHandler) error VerifyLeaderSignature(header data.HeaderHandler) error VerifySignature(header data.HeaderHandler) error IsInterfaceNil() bool }
HeaderSigVerifier encapsulates methods that check if header signature is correct
type PoolAdder ¶
type PoolAdder interface { Put(key []byte, value interface{}, sizeInBytes int) (evicted bool) IsInterfaceNil() bool }
PoolAdder adds data in a key-value pool
type ScheduledProcessorWrapperArgs ¶
type ScheduledProcessorWrapperArgs struct { SyncTimer ntp.SyncTimer Processor process.ScheduledBlockProcessor RoundTimeDurationHandler process.RoundTimeDurationHandler }
ScheduledProcessorWrapperArgs holds the arguments required to instantiate the pipelineExecution
type Subround ¶
type Subround struct { ConsensusCoreHandler *ConsensusState Job func(ctx context.Context) bool // method does the Subround Job and send the result to the peers Check func() bool // method checks if the consensus of the Subround is done Extend func(subroundId int) // method is called when round time is out // contains filtered or unexported fields }
Subround struct contains the needed data for one Subround and the Subround properties. It defines a Subround with it's properties (it's ID, next Subround ID, it's duration, it's name) and also it has some handler functions which should be set. Job function will be the main function of this Subround, Extend function will handle the overtime situation of the Subround and Check function will decide if in this Subround the consensus is achieved
func NewSubround ¶
func NewSubround( previous int, current int, next int, startTime int64, endTime int64, name string, consensusState *ConsensusState, consensusStateChangedChannel chan bool, executeStoredMessages func(), container ConsensusCoreHandler, chainID []byte, currentPid core.PeerID, appStatusHandler core.AppStatusHandler, ) (*Subround, error)
NewSubround creates a new SubroundId object
func (*Subround) AppStatusHandler ¶
func (sr *Subround) AppStatusHandler() core.AppStatusHandler
AppStatusHandler method returns the appStatusHandler instance
func (Subround) ComputeSize ¶
ComputeSize method returns the number of messages received from the nodes belonging to the current jobDone group related to this subround
func (*Subround) ConsensusChannel ¶
ConsensusChannel method returns the consensus channel
func (Subround) ConsensusGroup ¶
func (rcns Subround) ConsensusGroup() []string
ConsensusGroup returns the consensus group ID's
func (Subround) ConsensusGroupIndex ¶
ConsensusGroupIndex returns the index of given public key in the current consensus group
func (Subround) ConsensusGroupSize ¶
func (rcns Subround) ConsensusGroupSize() int
ConsensusGroupSize returns the consensus group size
func (*Subround) CurrentPid ¶
CurrentPid returns the current p2p peer ID
func (*Subround) DoWork ¶
DoWork method actually does the work of this Subround. First it tries to do the Job of the Subround then it will Check the consensus. If the upper time limit of this Subround is reached, the Extend method will be called before returning. If this method returns true the chronology will advance to the next Subround.
func (Subround) FallbackThreshold ¶
FallbackThreshold returns the fallback threshold of agreements needed in the given subround id
func (*Subround) IsInterfaceNil ¶
IsInterfaceNil returns true if there is no value under the interface
func (Subround) IsNodeInConsensusGroup ¶
IsNodeInConsensusGroup method checks if the node is part of consensus group of the current round
func (Subround) IsNodeInEligibleList ¶
IsNodeInEligibleList method checks if the node is part of the eligible list
func (Subround) JobDone ¶
JobDone returns the state of the action done, by the node represented by the key parameter, in subround given by the subroundId parameter
func (Subround) ResetRoundState ¶
func (rcns Subround) ResetRoundState()
ResetRoundState method resets the state of each node from the current jobDone group, regarding to the consensus validatorRoundStates
func (Subround) ResetRoundStatus ¶
func (rstatus Subround) ResetRoundStatus()
ResetRoundStatus method resets the state of each subround
func (Subround) SelfConsensusGroupIndex ¶
SelfConsensusGroupIndex returns the index of self public key in current consensus group
func (Subround) SelfJobDone ¶
SelfJobDone returns the self state of the action done in subround given by the subroundId parameter
func (Subround) SelfPubKey ¶
func (rcns Subround) SelfPubKey() string
SelfPubKey returns selfPubKey ID
func (Subround) SetConsensusGroup ¶
func (rcns Subround) SetConsensusGroup(consensusGroup []string)
SetConsensusGroup sets the consensus group ID's
func (Subround) SetConsensusGroupSize ¶
func (rcns Subround) SetConsensusGroupSize(consensusGroudpSize int)
SetConsensusGroupSize sets the consensus group size
func (Subround) SetEligibleList ¶
func (rcns Subround) SetEligibleList(eligibleList map[string]struct{})
SetEligibleList sets the eligible list ID's
func (Subround) SetFallbackThreshold ¶
SetFallbackThreshold sets the fallback threshold of agreements needed in the given subround id
func (Subround) SetJobDone ¶
SetJobDone set the state of the action done, by the node represented by the key parameter, in subround given by the subroundId parameter
func (Subround) SetSelfJobDone ¶
SetSelfJobDone set the self state of the action done in subround given by the subroundId parameter
func (Subround) SetSelfPubKey ¶
func (rcns Subround) SetSelfPubKey(selfPubKey string)
SetSelfPubKey sets selfPubKey ID
func (Subround) SetStatus ¶
func (rstatus Subround) SetStatus(subroundId int, subroundStatus SubroundStatus)
SetStatus sets the status of the given subround id
func (Subround) SetThreshold ¶
SetThreshold sets the threshold of agreements needed in the given subround id
func (Subround) Status ¶
func (rstatus Subround) Status(subroundId int) SubroundStatus
Status returns the status of the given subround id
type SubroundStatus ¶
type SubroundStatus int
SubroundStatus defines the type used to refer the state of the current subround
const ( // SsNotFinished defines the un-finished state of the subround SsNotFinished SubroundStatus = iota // SsFinished defines the finished state of the subround SsFinished )
type SubroundsFactory ¶
SubroundsFactory encapsulates the methods specifically for a subrounds factory type (bls, bn) for different consensus types
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker defines the data needed by spos to communicate between nodes which are in the validators group
func NewWorker ¶
func NewWorker(args *WorkerArgs) (*Worker, error)
NewWorker creates a new Worker object
func (*Worker) AddReceivedHeaderHandler ¶
func (wrk *Worker) AddReceivedHeaderHandler(handler func(data.HeaderHandler))
AddReceivedHeaderHandler adds a new handler function for a received header
func (*Worker) AddReceivedMessageCall ¶
func (wrk *Worker) AddReceivedMessageCall(messageType consensus.MessageType, receivedMessageCall func(ctx context.Context, cnsDta *consensus.Message) bool)
AddReceivedMessageCall adds a new handler function for a received messege type
func (*Worker) DisplayStatistics ¶
func (wrk *Worker) DisplayStatistics()
DisplayStatistics logs the consensus messages split on proposed headers
func (*Worker) ExecuteStoredMessages ¶
func (wrk *Worker) ExecuteStoredMessages()
ExecuteStoredMessages tries to execute all the messages received which are valid for execution
func (*Worker) GetConsensusStateChangedChannel ¶
GetConsensusStateChangedChannel gets the channel for the consensusStateChanged
func (*Worker) IsInterfaceNil ¶
IsInterfaceNil returns true if there is no value under the interface
func (*Worker) ProcessReceivedMessage ¶
func (wrk *Worker) ProcessReceivedMessage(message p2p.MessageP2P, fromConnectedPeer core.PeerID) error
ProcessReceivedMessage method redirects the received message to the channel which should handle it
func (*Worker) ReceivedHeader ¶
func (wrk *Worker) ReceivedHeader(headerHandler data.HeaderHandler, _ []byte)
ReceivedHeader process the received header, calling each received header handler registered in worker instance
func (*Worker) RemoveAllReceivedMessagesCalls ¶
func (wrk *Worker) RemoveAllReceivedMessagesCalls()
RemoveAllReceivedMessagesCalls removes all the functions handlers
func (*Worker) ResetConsensusMessages ¶
func (wrk *Worker) ResetConsensusMessages()
ResetConsensusMessages resets at the start of each round all the previous consensus messages received
func (*Worker) StartWorking ¶
func (wrk *Worker) StartWorking()
StartWorking actually starts the consensus working mechanism
type WorkerArgs ¶
type WorkerArgs struct { ConsensusService ConsensusService BlockChain data.ChainHandler BlockProcessor process.BlockProcessor ScheduledProcessor consensus.ScheduledProcessor Bootstrapper process.Bootstrapper BroadcastMessenger consensus.BroadcastMessenger ConsensusState *ConsensusState ForkDetector process.ForkDetector Marshalizer marshal.Marshalizer Hasher hashing.Hasher RoundHandler consensus.RoundHandler ShardCoordinator sharding.Coordinator PeerSignatureHandler crypto.PeerSignatureHandler SyncTimer ntp.SyncTimer HeaderSigVerifier HeaderSigVerifier HeaderIntegrityVerifier process.HeaderIntegrityVerifier ChainID []byte NetworkShardingCollector consensus.NetworkShardingCollector AntifloodHandler consensus.P2PAntifloodHandler PoolAdder PoolAdder SignatureSize int PublicKeySize int AppStatusHandler core.AppStatusHandler NodeRedundancyHandler consensus.NodeRedundancyHandler }
WorkerArgs holds the consensus worker arguments
type WorkerHandler ¶
type WorkerHandler interface { Close() error StartWorking() // AddReceivedMessageCall adds a new handler function for a received message type AddReceivedMessageCall(messageType consensus.MessageType, receivedMessageCall func(ctx context.Context, cnsDta *consensus.Message) bool) // AddReceivedHeaderHandler adds a new handler function for a received header AddReceivedHeaderHandler(handler func(data.HeaderHandler)) // RemoveAllReceivedMessagesCalls removes all the functions handlers RemoveAllReceivedMessagesCalls() // ProcessReceivedMessage method redirects the received message to the channel which should handle it ProcessReceivedMessage(message p2p.MessageP2P, fromConnectedPeer core.PeerID) error // Extend does an extension for the subround with subroundId Extend(subroundId int) // GetConsensusStateChangedChannel gets the channel for the consensusStateChanged GetConsensusStateChangedChannel() chan bool // ExecuteStoredMessages tries to execute all the messages received which are valid for execution ExecuteStoredMessages() // DisplayStatistics method displays statistics of worker at the end of the round DisplayStatistics() // ReceivedHeader method is a wired method through which worker will receive headers from network ReceivedHeader(headerHandler data.HeaderHandler, headerHash []byte) // ResetConsensusMessages resets at the start of each round all the previous consensus messages received ResetConsensusMessages() // IsInterfaceNil returns true if there is no value under the interface IsInterfaceNil() bool }
WorkerHandler represents the interface for the SposWorker