Versions in this module Expand all Collapse all v1 v1.999.0 Nov 17, 2022 Changes in this version + const LeaderPeerHonestyDecreaseFactor + const LeaderPeerHonestyIncreaseFactor + const MaxNumOfMessageTypeAccepted + const MaxThresholdPercent + const ValidatorPeerHonestyDecreaseFactor + const ValidatorPeerHonestyIncreaseFactor + var ErrEmptyConsensusGroup = errors.New("consensusGroup is empty") + var ErrInvalidBodySize = errors.New("invalid body size") + var ErrInvalidCacheSize = errors.New("invalid cache size") + var ErrInvalidChainID = errors.New("invalid chain ID in consensus") + var ErrInvalidHeader = errors.New("header is invalid") + var ErrInvalidHeaderHashSize = errors.New("invalid header hash size") + var ErrInvalidHeaderSize = errors.New("invalid header size") + var ErrInvalidKey = errors.New("map key is invalid") + var ErrInvalidMessage = errors.New("invalid message") + var ErrInvalidMessageType = errors.New("invalid message type") + var ErrInvalidMetaHeader = errors.New("meta header is invalid") + var ErrInvalidPublicKeyBitmapSize = errors.New("invalid public key bitmap size") + var ErrInvalidPublicKeySize = errors.New("invalid public key size") + var ErrInvalidSignature = errors.New("signature is invalid") + var ErrInvalidSignatureSize = errors.New("invalid signature size") + var ErrMessageForFutureRound = errors.New("message is for future round") + var ErrMessageForPastRound = errors.New("message is for past round") + var ErrMessageFromItself = errors.New("message is from itself") + var ErrMessageTypeLimitReached = errors.New("consensus message type limit has been reached") + var ErrNilAlarmScheduler = errors.New("alarm scheduler is nil") + var ErrNilAntifloodHandler = errors.New("nil antiflood handler") + var ErrNilAppStatusHandler = errors.New("nil AppStatusHandler") + var ErrNilBlockChain = errors.New("blockchain is nil") + var ErrNilBlockProcessor = errors.New("block processor is nil") + var ErrNilBlsPrivateKey = errors.New("BLS private key should not be nil") + var ErrNilBlsSingleSigner = errors.New("BLS single signer should not be nil") + var ErrNilBody = errors.New("body is nil") + var ErrNilBootstrapper = errors.New("bootstrapper is nil") + var ErrNilBroadcastMessenger = errors.New("broadcast messenger is nil") + var ErrNilChannel = errors.New("channel is nil") + var ErrNilChronologyHandler = errors.New("chronology handler is nil") + var ErrNilConsensusCore = errors.New("consensus core is nil") + var ErrNilConsensusGroup = errors.New("consensusGroup is null") + var ErrNilConsensusService = errors.New("consensus service is nil") + var ErrNilConsensusState = errors.New("consensus state is nil") + var ErrNilDataToProcess = errors.New("nil data to process") + var ErrNilExecuteStoredMessages = errors.New("executeStoredMessages is nil") + var ErrNilFallbackHeaderValidator = errors.New("nil fallback header validator") + var ErrNilForkDetector = errors.New("fork detector is nil") + var ErrNilHasher = errors.New("hasher is nil") + var ErrNilHeader = errors.New("header is nil") + var ErrNilHeaderHash = errors.New("header hash is nil") + var ErrNilHeaderIntegrityVerifier = errors.New("nil header integrity verifier") + var ErrNilHeaderSigVerifier = errors.New("nil header sig verifier") + var ErrNilHeadersSubscriber = errors.New("headers subscriber is nil") + var ErrNilInterceptorsContainer = errors.New("interceptor container is nil") + var ErrNilMarshalizer = errors.New("marshalizer is nil") + var ErrNilMessage = errors.New("nil message") + var ErrNilMessenger = errors.New("messenger is nil") + var ErrNilMetaHeader = errors.New("meta header is nil") + var ErrNilMultiSigner = errors.New("multiSigner is nil") + var ErrNilNetworkShardingCollector = errors.New("nil network sharding collector") + var ErrNilNodeRedundancyHandler = errors.New("nil node redundancy handler") + var ErrNilNodesCoordinator = errors.New("validator group selector is nil") + var ErrNilParameter = errors.New("parameter is nil") + var ErrNilPeerHonestyHandler = errors.New("nil peer honesty handler") + var ErrNilPeerSignatureHandler = errors.New("trying to set nil peerSignatureHandler") + var ErrNilPoolAdder = errors.New("nil pool adder") + var ErrNilPrivateKey = errors.New("private key is nil") + var ErrNilRoundHandler = errors.New("roundHandler is nil") + var ErrNilRoundState = errors.New("round state is nil") + var ErrNilScheduledProcessor = errors.New("nil scheduled processor") + var ErrNilShardCoordinator = errors.New("shard coordinator is nil") + var ErrNilSignature = errors.New("signature is nil") + var ErrNilSubround = errors.New("subround is nil") + var ErrNilSyncTimer = errors.New("sync timer is nil") + var ErrNilWorker = errors.New("worker is nil") + var ErrNilWorkerArgs = errors.New("worker args is nil") + var ErrNodeIsNotInEligibleList = errors.New("node is not in eligible list") + var ErrNotFoundInConsensus = errors.New("self not found in consensus group") + var ErrOriginatorMismatch = errors.New("consensus message originator mismatch") + var ErrRoundCanceled = errors.New("round is canceled") + 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 struct + ChainID []byte + ConsensusService ConsensusService + ConsensusState *ConsensusState + HasherSize int + PeerSignatureHandler crypto.PeerSignatureHandler + PublicKeySize int + SignatureSize int + type ConsensusCore struct + func NewConsensusCore(args *ConsensusCoreArgs) (*ConsensusCore, error) + 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 struct + AntifloodHandler consensus.P2PAntifloodHandler + BlockChain data.ChainHandler + BlockProcessor process.BlockProcessor + BlsPrivateKey crypto.PrivateKey + BlsSingleSigner crypto.SingleSigner + Bootstrapper process.Bootstrapper + BroadcastMessenger consensus.BroadcastMessenger + ChronologyHandler consensus.ChronologyHandler + EpochStartRegistrationHandler epochStart.RegistrationHandler + FallbackHeaderValidator consensus.FallbackHeaderValidator + Hasher hashing.Hasher + HeaderSigVerifier consensus.HeaderSigVerifier + Marshalizer marshal.Marshalizer + MultiSigner crypto.MultiSigner + NodeRedundancyHandler consensus.NodeRedundancyHandler + NodesCoordinator nodesCoordinator.NodesCoordinator + PeerHonestyHandler consensus.PeerHonestyHandler + RoundHandler consensus.RoundHandler + ScheduledProcessor consensus.ScheduledProcessor + ShardCoordinator sharding.Coordinator + SyncTimer ntp.SyncTimer + type ConsensusCoreHandler interface + BlockProcessor func() process.BlockProcessor + Blockchain func() data.ChainHandler + BootStrapper func() process.Bootstrapper + BroadcastMessenger func() consensus.BroadcastMessenger + Chronology func() consensus.ChronologyHandler + EpochStartRegistrationHandler func() epochStart.RegistrationHandler + FallbackHeaderValidator func() consensus.FallbackHeaderValidator + GetAntiFloodHandler func() consensus.P2PAntifloodHandler + Hasher func() hashing.Hasher + HeaderSigVerifier func() consensus.HeaderSigVerifier + IsInterfaceNil func() bool + Marshalizer func() marshal.Marshalizer + MultiSigner func() crypto.MultiSigner + NodeRedundancyHandler func() consensus.NodeRedundancyHandler + NodesCoordinator func() nodesCoordinator.NodesCoordinator + PeerHonestyHandler func() consensus.PeerHonestyHandler + PrivateKey func() crypto.PrivateKey + RoundHandler func() consensus.RoundHandler + ScheduledProcessor func() consensus.ScheduledProcessor + ShardCoordinator func() sharding.Coordinator + SingleSigner func() crypto.SingleSigner + SyncTimer func() ntp.SyncTimer + type ConsensusDataIndexer interface + IsInterfaceNil func() bool + SaveRoundsInfo func(roundsInfos []*indexer.RoundInfo) + type ConsensusService interface + CanProceed func(*ConsensusState, consensus.MessageType) bool + GetMaxMessagesInARoundPerPeer func() uint32 + GetMessageRange func() []consensus.MessageType + GetStringValue func(consensus.MessageType) string + GetSubroundName func(int) string + InitReceivedMessages func() map[consensus.MessageType][]*consensus.Message + IsInterfaceNil func() bool + IsMessageTypeValid func(consensus.MessageType) bool + IsMessageWithBlockBody func(consensus.MessageType) bool + IsMessageWithBlockBodyAndHeader func(consensus.MessageType) bool + IsMessageWithBlockHeader func(consensus.MessageType) bool + IsMessageWithFinalInfo func(consensus.MessageType) bool + IsMessageWithSignature func(consensus.MessageType) bool + IsSubroundSignature func(int) bool + IsSubroundStartRound func(int) bool + type ConsensusState struct + Body data.BodyHandler + Data []byte + ExtendedCalled bool + Header data.HeaderHandler + RoundCanceled bool + RoundIndex int64 + RoundTimeStamp time.Time + WaitingAllSignaturesTimeOut bool + func NewConsensusState(roundConsensus *roundConsensus, roundThreshold *roundThreshold, ...) *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 (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 (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 (cns *ConsensusState) ProcessingBlock() bool + func (cns *ConsensusState) ResetConsensusState() + func (cns *ConsensusState) SetProcessingBlock(processingBlock 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 (rcns ConsensusState) IsNodeInConsensusGroup(node string) bool + func (rcns ConsensusState) IsNodeInEligibleList(node string) bool + func (rcns ConsensusState) JobDone(key string, subroundId int) (bool, error) + func (rcns ConsensusState) ResetRoundState() + 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 (rcns ConsensusState) SetJobDone(key string, subroundId int, value bool) error + func (rcns ConsensusState) SetSelfJobDone(subroundId int, value bool) error + func (rcns ConsensusState) SetSelfPubKey(selfPubKey string) + func (rstatus ConsensusState) ResetRoundStatus() + func (rstatus ConsensusState) SetStatus(subroundId int, subroundStatus SubroundStatus) + func (rstatus ConsensusState) Status(subroundId int) SubroundStatus + func (rthr ConsensusState) FallbackThreshold(subroundId int) int + func (rthr ConsensusState) SetFallbackThreshold(subroundId int, threshold int) + func (rthr ConsensusState) SetThreshold(subroundId int, threshold int) + func (rthr ConsensusState) Threshold(subroundId int) int + type HeaderSigVerifier interface + IsInterfaceNil func() bool + VerifyLeaderSignature func(header data.HeaderHandler) error + VerifyRandSeed func(header data.HeaderHandler) error + VerifySignature func(header data.HeaderHandler) error + type PoolAdder interface + IsInterfaceNil func() bool + Put func(key []byte, value interface{}, sizeInBytes int) (evicted bool) + type ScheduledProcessorWrapperArgs struct + Processor process.ScheduledBlockProcessor + RoundTimeDurationHandler process.RoundTimeDurationHandler + SyncTimer ntp.SyncTimer + type Subround struct + Check func() bool + Extend func(subroundId int) + Job func(ctx context.Context) bool + func NewSubround(previous int, current int, next int, startTime int64, endTime int64, ...) (*Subround, error) + func (rcns Subround) ComputeSize(subroundId int) int + func (rcns Subround) ConsensusGroup() []string + func (rcns Subround) ConsensusGroupIndex(pubKey string) (int, error) + func (rcns Subround) ConsensusGroupSize() int + 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 (rcns Subround) ResetRoundState() + 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 (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) ResetRoundStatus() + func (rstatus Subround) SetStatus(subroundId int, subroundStatus SubroundStatus) + func (rstatus Subround) Status(subroundId int) SubroundStatus + func (rthr Subround) FallbackThreshold(subroundId int) int + func (rthr Subround) SetFallbackThreshold(subroundId int, threshold int) + func (rthr Subround) SetThreshold(subroundId int, threshold int) + func (rthr Subround) Threshold(subroundId int) int + func (sr *Subround) AppStatusHandler() core.AppStatusHandler + func (sr *Subround) ChainID() []byte + func (sr *Subround) ConsensusChannel() chan bool + 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 (sr *Subround) IsInterfaceNil() bool + func (sr *Subround) Name() string + func (sr *Subround) Next() int + func (sr *Subround) Previous() int + func (sr *Subround) StartTime() int64 + type SubroundStatus int + const SsFinished + const SsNotFinished + type SubroundsFactory interface + GenerateSubrounds func() error + IsInterfaceNil func() bool + type Worker struct + func NewWorker(args *WorkerArgs) (*Worker, error) + 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 struct + AntifloodHandler consensus.P2PAntifloodHandler + AppStatusHandler core.AppStatusHandler + BlockChain data.ChainHandler + BlockProcessor process.BlockProcessor + Bootstrapper process.Bootstrapper + BroadcastMessenger consensus.BroadcastMessenger + ChainID []byte + ConsensusService ConsensusService + ConsensusState *ConsensusState + ForkDetector process.ForkDetector + Hasher hashing.Hasher + HeaderIntegrityVerifier process.HeaderIntegrityVerifier + HeaderSigVerifier HeaderSigVerifier + Marshalizer marshal.Marshalizer + NetworkShardingCollector consensus.NetworkShardingCollector + NodeRedundancyHandler consensus.NodeRedundancyHandler + PeerSignatureHandler crypto.PeerSignatureHandler + PoolAdder PoolAdder + PublicKeySize int + RoundHandler consensus.RoundHandler + ScheduledProcessor consensus.ScheduledProcessor + ShardCoordinator sharding.Coordinator + SignatureSize int + SyncTimer ntp.SyncTimer + type WorkerHandler interface + AddReceivedHeaderHandler func(handler func(data.HeaderHandler)) + AddReceivedMessageCall func(messageType consensus.MessageType, ...) + Close func() error + DisplayStatistics func() + ExecuteStoredMessages func() + Extend func(subroundId int) + GetConsensusStateChangedChannel func() chan bool + IsInterfaceNil func() bool + ProcessReceivedMessage func(message p2p.MessageP2P, fromConnectedPeer core.PeerID) error + ReceivedHeader func(headerHandler data.HeaderHandler, headerHash []byte) + RemoveAllReceivedMessagesCalls func() + ResetConsensusMessages func() + StartWorking func()