Documentation ¶
Index ¶
- Constants
- func ABlock(previousBlock interfaces.Block) interfaces.Block
- func CalculateBlockHash(block interfaces.Block) primitives.BlockHash
- func NewMockConfig(logger interfaces.Logger, instanceId primitives.InstanceId, ...) *interfaces.Config
- func NewMockConfigSimple() *interfaces.Config
- type BlocksPool
- type CommunicationMock
- func (g *CommunicationMock) CountMessagesSent(messageType protocol.MessageType, height primitives.BlockHeight, ...) int
- func (g *CommunicationMock) CountSentMessages(messageType protocol.MessageType) int
- func (g *CommunicationMock) DisableIncomingCommunication()
- func (g *CommunicationMock) DisableOutgoingCommunication()
- func (g *CommunicationMock) EnableIncomingCommunication()
- func (g *CommunicationMock) EnableOutgoingCommunication()
- func (g *CommunicationMock) GetSentMessages(messageType protocol.MessageType) []*interfaces.ConsensusRawMessage
- func (g *CommunicationMock) OnIncomingMessage(ctx context.Context, rawMessage *interfaces.ConsensusRawMessage)
- func (g *CommunicationMock) RegisterIncomingMessageHandler(cb func(ctx context.Context, message *interfaces.ConsensusRawMessage))
- func (g *CommunicationMock) ReturnAndMaybeCreateOutgoingChannelByTarget(ctx context.Context, target primitives.MemberId) chan *outgoingMessage
- func (g *CommunicationMock) ReturnOutgoingChannelByTarget(target primitives.MemberId) chan *outgoingMessage
- func (g *CommunicationMock) SendConsensusMessage(ctx context.Context, targets []primitives.MemberId, ...) error
- func (g *CommunicationMock) SendToNode(ctx context.Context, receiverMemberId primitives.MemberId, ...)
- func (g *CommunicationMock) SetIncomingWhitelist(incomingWhitelist []primitives.MemberId)
- func (g *CommunicationMock) SetMessagesMaxDelay(duration time.Duration)
- func (g *CommunicationMock) SetOutgoingWhitelist(outgoingWhitelist []primitives.MemberId)
- type Discovery
- func (d *Discovery) AllCommunicationsMemberIds() []primitives.MemberId
- func (d *Discovery) Communications(memberIds []primitives.MemberId) []*CommunicationMock
- func (d *Discovery) GetCommunicationById(memberId primitives.MemberId) *CommunicationMock
- func (d *Discovery) RegisterCommunication(memberId primitives.MemberId, communication *CommunicationMock)
- func (d *Discovery) UnregisterCommunication(memberId primitives.MemberId)
- type ElectionTriggerMock
- func (et *ElectionTriggerMock) CalcTimeout(view primitives.View) time.Duration
- func (et *ElectionTriggerMock) ElectionChannel() chan *interfaces.ElectionTrigger
- func (et *ElectionTriggerMock) GetRegisteredHeight() primitives.BlockHeight
- func (et *ElectionTriggerMock) InvokeElectionHandler()
- func (et *ElectionTriggerMock) ManualTrigger(ctx context.Context, hv *state.HeightView) <-chan struct{}
- func (et *ElectionTriggerMock) RegisterOnElection(blockHeight primitives.BlockHeight, view primitives.View, ...)
- func (et *ElectionTriggerMock) Stop()
- type FakeMembership
- func (m *FakeMembership) MyMemberId() primitives.MemberId
- func (m *FakeMembership) RequestCommitteeForBlockProof(ctx context.Context, blockHeight primitives.BlockHeight, ...) ([]interfaces.CommitteeMember, error)
- func (m *FakeMembership) RequestOrderedCommittee(ctx context.Context, blockHeight primitives.BlockHeight, randomSeed uint64, ...) ([]interfaces.CommitteeMember, error)
- type InMemoryBlockchain
- func (bs *InMemoryBlockchain) AppendBlockToChain(block interfaces.Block, blockProof []byte)
- func (bs *InMemoryBlockchain) BlockAndProofAt(height primitives.BlockHeight) (interfaces.Block, []byte)
- func (bs *InMemoryBlockchain) Count() int
- func (bs *InMemoryBlockchain) LastBlock() interfaces.Block
- func (bs *InMemoryBlockchain) LastBlockProof() []byte
- func (bs *InMemoryBlockchain) WithMemberId(memberId primitives.MemberId) *InMemoryBlockchain
- type MockBlock
- type MockKeyManager
- func (km *MockKeyManager) AggregateRandomSeed(blockHeight primitives.BlockHeight, ...) primitives.RandomSeedSignature
- func (km *MockKeyManager) DisableConsensusMessageVerification()
- func (km *MockKeyManager) SignConsensusMessage(ctx context.Context, blockHeight primitives.BlockHeight, content []byte) primitives.Signature
- func (km *MockKeyManager) SignRandomSeed(ctx context.Context, blockHeight primitives.BlockHeight, content []byte) primitives.RandomSeedSignature
- func (km *MockKeyManager) VerifyConsensusMessage(blockHeight primitives.BlockHeight, content []byte, ...) error
- func (km *MockKeyManager) VerifyRandomSeed(blockHeight primitives.BlockHeight, content []byte, ...) error
- func (km *MockKeyManager) VerifyRandomSeedHistory(idx int) *VerifyRandomSeedCallParams
- type MockState
- type PausableBlockUtils
- func (b *PausableBlockUtils) RequestNewBlockProposal(ctx context.Context, blockHeight primitives.BlockHeight, _ primitives.MemberId, ...) (interfaces.Block, primitives.BlockHash)
- func (b *PausableBlockUtils) ValidateBlockCommitment(blockHeight primitives.BlockHeight, block interfaces.Block, ...) bool
- func (b *PausableBlockUtils) ValidateBlockProposal(ctx context.Context, blockHeight primitives.BlockHeight, _ primitives.MemberId, ...) error
- func (b *PausableBlockUtils) WithFailingBlockProposalValidations() *PausableBlockUtils
- type SubscriptionValue
- type TermMessagesHandlerMock
- func (tmh *TermMessagesHandlerMock) HandleCommit(cm *interfaces.CommitMessage)
- func (tmh *TermMessagesHandlerMock) HandleNewView(nvm *interfaces.NewViewMessage)
- func (tmh *TermMessagesHandlerMock) HandlePrePrepare(ppm *interfaces.PreprepareMessage)
- func (tmh *TermMessagesHandlerMock) HandlePrepare(pm *interfaces.PrepareMessage)
- func (tmh *TermMessagesHandlerMock) HandleViewChange(vcm *interfaces.ViewChangeMessage)
- type VerifyRandomSeedCallParams
Constants ¶
View Source
const BLOCK_HEIGHT_DONT_CARE = math.MaxUint64
View Source
const VIEW_DONT_CARE = math.MaxUint64
Variables ¶
This section is empty.
Functions ¶
func ABlock ¶
func ABlock(previousBlock interfaces.Block) interfaces.Block
func CalculateBlockHash ¶
func CalculateBlockHash(block interfaces.Block) primitives.BlockHash
func NewMockConfig ¶ added in v0.2.0
func NewMockConfig(logger interfaces.Logger, instanceId primitives.InstanceId, membership interfaces.Membership, blockUtils interfaces.BlockUtils, keyManager interfaces.KeyManager, electionSched interfaces.ElectionScheduler, communication interfaces.Communication) *interfaces.Config
func NewMockConfigSimple ¶ added in v0.2.4
func NewMockConfigSimple() *interfaces.Config
Types ¶
type BlocksPool ¶
type BlocksPool struct {
// contains filtered or unexported fields
}
func NewBlocksPool ¶
func NewBlocksPool(upcomingBlocks []interfaces.Block) *BlocksPool
func (*BlocksPool) PopBlock ¶
func (bp *BlocksPool) PopBlock(prevBlock interfaces.Block) interfaces.Block
type CommunicationMock ¶
type CommunicationMock struct {
// contains filtered or unexported fields
}
func NewCommunication ¶
func NewCommunication(memberId primitives.MemberId, discovery *Discovery, log interfaces.Logger) *CommunicationMock
func (*CommunicationMock) CountMessagesSent ¶ added in v0.2.0
func (g *CommunicationMock) CountMessagesSent(messageType protocol.MessageType, height primitives.BlockHeight, view primitives.View, target primitives.MemberId) int
func (*CommunicationMock) CountSentMessages ¶
func (g *CommunicationMock) CountSentMessages(messageType protocol.MessageType) int
TODO REMOVE THIS REDUNDANT METHOD
func (*CommunicationMock) DisableIncomingCommunication ¶ added in v0.2.0
func (g *CommunicationMock) DisableIncomingCommunication()
func (*CommunicationMock) DisableOutgoingCommunication ¶ added in v0.2.0
func (g *CommunicationMock) DisableOutgoingCommunication()
func (*CommunicationMock) EnableIncomingCommunication ¶ added in v0.2.0
func (g *CommunicationMock) EnableIncomingCommunication()
func (*CommunicationMock) EnableOutgoingCommunication ¶ added in v0.2.0
func (g *CommunicationMock) EnableOutgoingCommunication()
func (*CommunicationMock) GetSentMessages ¶
func (g *CommunicationMock) GetSentMessages(messageType protocol.MessageType) []*interfaces.ConsensusRawMessage
TODO Refactor this, maybe get the data from messagesHistory instead of statsSentMessages
func (*CommunicationMock) OnIncomingMessage ¶ added in v0.2.0
func (g *CommunicationMock) OnIncomingMessage(ctx context.Context, rawMessage *interfaces.ConsensusRawMessage)
func (*CommunicationMock) RegisterIncomingMessageHandler ¶ added in v0.2.0
func (g *CommunicationMock) RegisterIncomingMessageHandler(cb func(ctx context.Context, message *interfaces.ConsensusRawMessage))
func (*CommunicationMock) ReturnAndMaybeCreateOutgoingChannelByTarget ¶ added in v0.2.0
func (g *CommunicationMock) ReturnAndMaybeCreateOutgoingChannelByTarget(ctx context.Context, target primitives.MemberId) chan *outgoingMessage
func (*CommunicationMock) ReturnOutgoingChannelByTarget ¶ added in v0.2.0
func (g *CommunicationMock) ReturnOutgoingChannelByTarget(target primitives.MemberId) chan *outgoingMessage
func (*CommunicationMock) SendConsensusMessage ¶
func (g *CommunicationMock) SendConsensusMessage(ctx context.Context, targets []primitives.MemberId, message *interfaces.ConsensusRawMessage) error
func (*CommunicationMock) SendToNode ¶
func (g *CommunicationMock) SendToNode(ctx context.Context, receiverMemberId primitives.MemberId, consensusRawMessage *interfaces.ConsensusRawMessage)
func (*CommunicationMock) SetIncomingWhitelist ¶
func (g *CommunicationMock) SetIncomingWhitelist(incomingWhitelist []primitives.MemberId)
func (*CommunicationMock) SetMessagesMaxDelay ¶
func (g *CommunicationMock) SetMessagesMaxDelay(duration time.Duration)
func (*CommunicationMock) SetOutgoingWhitelist ¶
func (g *CommunicationMock) SetOutgoingWhitelist(outgoingWhitelist []primitives.MemberId)
type Discovery ¶
type Discovery struct {
// contains filtered or unexported fields
}
func NewDiscovery ¶
func NewDiscovery() *Discovery
func (*Discovery) AllCommunicationsMemberIds ¶
func (d *Discovery) AllCommunicationsMemberIds() []primitives.MemberId
func (*Discovery) Communications ¶
func (d *Discovery) Communications(memberIds []primitives.MemberId) []*CommunicationMock
func (*Discovery) GetCommunicationById ¶
func (d *Discovery) GetCommunicationById(memberId primitives.MemberId) *CommunicationMock
func (*Discovery) RegisterCommunication ¶
func (d *Discovery) RegisterCommunication(memberId primitives.MemberId, communication *CommunicationMock)
func (*Discovery) UnregisterCommunication ¶
func (d *Discovery) UnregisterCommunication(memberId primitives.MemberId)
type ElectionTriggerMock ¶
type ElectionTriggerMock struct {
// contains filtered or unexported fields
}
func NewMockElectionTrigger ¶
func NewMockElectionTrigger() *ElectionTriggerMock
func (*ElectionTriggerMock) CalcTimeout ¶
func (et *ElectionTriggerMock) CalcTimeout(view primitives.View) time.Duration
func (*ElectionTriggerMock) ElectionChannel ¶
func (et *ElectionTriggerMock) ElectionChannel() chan *interfaces.ElectionTrigger
func (*ElectionTriggerMock) GetRegisteredHeight ¶ added in v0.2.4
func (et *ElectionTriggerMock) GetRegisteredHeight() primitives.BlockHeight
func (*ElectionTriggerMock) InvokeElectionHandler ¶ added in v0.2.6
func (et *ElectionTriggerMock) InvokeElectionHandler()
func (*ElectionTriggerMock) ManualTrigger ¶
func (et *ElectionTriggerMock) ManualTrigger(ctx context.Context, hv *state.HeightView) <-chan struct{}
func (*ElectionTriggerMock) RegisterOnElection ¶
func (et *ElectionTriggerMock) RegisterOnElection(blockHeight primitives.BlockHeight, view primitives.View, cb func(blockHeight primitives.BlockHeight, view primitives.View, onElectionCB interfaces.OnElectionCallback))
func (*ElectionTriggerMock) Stop ¶
func (et *ElectionTriggerMock) Stop()
type FakeMembership ¶ added in v0.2.0
type FakeMembership struct {
// contains filtered or unexported fields
}
func NewFakeMembership ¶ added in v0.2.0
func NewFakeMembership(myMemberId primitives.MemberId, memberToWeight map[string]primitives.MemberWeight, discovery *Discovery, orderCommitteeByHeight bool) *FakeMembership
func (*FakeMembership) MyMemberId ¶ added in v0.2.0
func (m *FakeMembership) MyMemberId() primitives.MemberId
func (*FakeMembership) RequestCommitteeForBlockProof ¶ added in v0.3.1
func (m *FakeMembership) RequestCommitteeForBlockProof(ctx context.Context, blockHeight primitives.BlockHeight, prevBlockReferenceTime primitives.TimestampSeconds) ([]interfaces.CommitteeMember, error)
func (*FakeMembership) RequestOrderedCommittee ¶ added in v0.2.0
func (m *FakeMembership) RequestOrderedCommittee(ctx context.Context, blockHeight primitives.BlockHeight, randomSeed uint64, prevBlockReferenceTime primitives.TimestampSeconds) ([]interfaces.CommitteeMember, error)
type InMemoryBlockchain ¶ added in v0.2.0
type InMemoryBlockchain struct {
// contains filtered or unexported fields
}
func NewInMemoryBlockchain ¶ added in v0.2.0
func NewInMemoryBlockchain() *InMemoryBlockchain
func (*InMemoryBlockchain) AppendBlockToChain ¶ added in v0.2.0
func (bs *InMemoryBlockchain) AppendBlockToChain(block interfaces.Block, blockProof []byte)
func (*InMemoryBlockchain) BlockAndProofAt ¶ added in v0.2.0
func (bs *InMemoryBlockchain) BlockAndProofAt(height primitives.BlockHeight) (interfaces.Block, []byte)
func (*InMemoryBlockchain) Count ¶ added in v0.2.0
func (bs *InMemoryBlockchain) Count() int
func (*InMemoryBlockchain) LastBlock ¶ added in v0.2.0
func (bs *InMemoryBlockchain) LastBlock() interfaces.Block
func (*InMemoryBlockchain) LastBlockProof ¶ added in v0.2.0
func (bs *InMemoryBlockchain) LastBlockProof() []byte
func (*InMemoryBlockchain) WithMemberId ¶ added in v0.2.0
func (bs *InMemoryBlockchain) WithMemberId(memberId primitives.MemberId) *InMemoryBlockchain
type MockBlock ¶
MockBlock
func (*MockBlock) Height ¶
func (b *MockBlock) Height() primitives.BlockHeight
func (*MockBlock) ReferenceTime ¶ added in v0.3.0
func (b *MockBlock) ReferenceTime() primitives.TimestampSeconds
type MockKeyManager ¶
type MockKeyManager struct { FailFutureVerifications bool // contains filtered or unexported fields }
func NewMockKeyManager ¶
func NewMockKeyManager(memberId primitives.MemberId, rejectedMemberIds ...primitives.MemberId) *MockKeyManager
func (*MockKeyManager) AggregateRandomSeed ¶
func (km *MockKeyManager) AggregateRandomSeed(blockHeight primitives.BlockHeight, randomSeedShares []*protocol.SenderSignature) primitives.RandomSeedSignature
func (*MockKeyManager) DisableConsensusMessageVerification ¶ added in v0.2.4
func (km *MockKeyManager) DisableConsensusMessageVerification()
func (*MockKeyManager) SignConsensusMessage ¶
func (km *MockKeyManager) SignConsensusMessage(ctx context.Context, blockHeight primitives.BlockHeight, content []byte) primitives.Signature
func (*MockKeyManager) SignRandomSeed ¶
func (km *MockKeyManager) SignRandomSeed(ctx context.Context, blockHeight primitives.BlockHeight, content []byte) primitives.RandomSeedSignature
func (*MockKeyManager) VerifyConsensusMessage ¶
func (km *MockKeyManager) VerifyConsensusMessage(blockHeight primitives.BlockHeight, content []byte, sender *protocol.SenderSignature) error
func (*MockKeyManager) VerifyRandomSeed ¶
func (km *MockKeyManager) VerifyRandomSeed(blockHeight primitives.BlockHeight, content []byte, sender *protocol.SenderSignature) error
func (*MockKeyManager) VerifyRandomSeedHistory ¶
func (km *MockKeyManager) VerifyRandomSeedHistory(idx int) *VerifyRandomSeedCallParams
type MockState ¶ added in v0.2.0
func NewMockState ¶ added in v0.2.0
func NewMockState() *MockState
func (*MockState) WithHeightView ¶ added in v0.2.0
func (s *MockState) WithHeightView(h primitives.BlockHeight, v primitives.View) *MockState
type PausableBlockUtils ¶ added in v0.2.0
type PausableBlockUtils struct { interfaces.BlockUtils //PauseOnRequestNewBlock bool RequestNewBlockCallsLeftUntilItPausesWhenCounterIsZero int64 RequestNewBlockLatch *test.Latch ValidationLatch *test.Latch PauseOnValidateBlock bool // contains filtered or unexported fields }
func NewMockBlockUtils ¶
func NewMockBlockUtils(memberId primitives.MemberId, blocksPool *BlocksPool, logger interfaces.Logger) *PausableBlockUtils
func (*PausableBlockUtils) RequestNewBlockProposal ¶ added in v0.2.0
func (b *PausableBlockUtils) RequestNewBlockProposal(ctx context.Context, blockHeight primitives.BlockHeight, _ primitives.MemberId, prevBlock interfaces.Block) (interfaces.Block, primitives.BlockHash)
func (*PausableBlockUtils) ValidateBlockCommitment ¶ added in v0.2.0
func (b *PausableBlockUtils) ValidateBlockCommitment(blockHeight primitives.BlockHeight, block interfaces.Block, blockHash primitives.BlockHash) bool
func (*PausableBlockUtils) ValidateBlockProposal ¶ added in v0.2.0
func (b *PausableBlockUtils) ValidateBlockProposal(ctx context.Context, blockHeight primitives.BlockHeight, _ primitives.MemberId, block interfaces.Block, blockHash primitives.BlockHash, prevBlock interfaces.Block) error
func (*PausableBlockUtils) WithFailingBlockProposalValidations ¶ added in v0.2.0
func (b *PausableBlockUtils) WithFailingBlockProposalValidations() *PausableBlockUtils
type SubscriptionValue ¶
type SubscriptionValue struct {
// contains filtered or unexported fields
}
type TermMessagesHandlerMock ¶
type TermMessagesHandlerMock struct { HistoryPP []*interfaces.PreprepareMessage HistoryP []*interfaces.PrepareMessage HistoryC []*interfaces.CommitMessage HistoryNV []*interfaces.NewViewMessage HistoryVC []*interfaces.ViewChangeMessage }
func NewTermMessagesHandlerMock ¶
func NewTermMessagesHandlerMock() *TermMessagesHandlerMock
func (*TermMessagesHandlerMock) HandleCommit ¶
func (tmh *TermMessagesHandlerMock) HandleCommit(cm *interfaces.CommitMessage)
func (*TermMessagesHandlerMock) HandleNewView ¶
func (tmh *TermMessagesHandlerMock) HandleNewView(nvm *interfaces.NewViewMessage)
func (*TermMessagesHandlerMock) HandlePrePrepare ¶
func (tmh *TermMessagesHandlerMock) HandlePrePrepare(ppm *interfaces.PreprepareMessage)
func (*TermMessagesHandlerMock) HandlePrepare ¶
func (tmh *TermMessagesHandlerMock) HandlePrepare(pm *interfaces.PrepareMessage)
func (*TermMessagesHandlerMock) HandleViewChange ¶
func (tmh *TermMessagesHandlerMock) HandleViewChange(vcm *interfaces.ViewChangeMessage)
type VerifyRandomSeedCallParams ¶
type VerifyRandomSeedCallParams struct { BlockHeight primitives.BlockHeight Content []byte Sender *protocol.SenderSignature }
Click to show internal directories.
Click to hide internal directories.