Documentation ¶
Overview ¶
Package weakcoin is a generated GoMock package.
nolint
Index ¶
- type Message
- type Mockallowance
- type MockallowanceMockRecorder
- type MocknonceFetcher
- type MocknonceFetcherMockRecorder
- type MockvrfSigner
- type MockvrfSignerMockRecorder
- type MockvrfVerifier
- type MockvrfVerifierMockRecorder
- type OptionFunc
- type VrfMessage
- type WeakCoin
- func (wc *WeakCoin) FinishEpoch(ctx context.Context, epoch types.EpochID)
- func (wc *WeakCoin) FinishRound(ctx context.Context)
- func (wc *WeakCoin) Get(ctx context.Context, epoch types.EpochID, round types.RoundID) (bool, error)
- func (wc *WeakCoin) HandleProposal(ctx context.Context, peer p2p.Peer, msg []byte) error
- func (wc *WeakCoin) StartEpoch(ctx context.Context, epoch types.EpochID)
- func (wc *WeakCoin) StartRound(ctx context.Context, round types.RoundID, nonce *types.VRFPostIndex)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message struct { Epoch types.EpochID Round types.RoundID Unit uint32 NodeID types.NodeID VrfSignature types.VrfSignature }
Message defines weak coin message format.
func (*Message) DecodeScale ¶
func (*Message) EncodeScale ¶
type Mockallowance ¶
type Mockallowance struct {
// contains filtered or unexported fields
}
Mockallowance is a mock of allowance interface.
func NewMockallowance ¶
func NewMockallowance(ctrl *gomock.Controller) *Mockallowance
NewMockallowance creates a new mock instance.
func (*Mockallowance) EXPECT ¶
func (m *Mockallowance) EXPECT() *MockallowanceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*Mockallowance) MinerAllowance ¶
MinerAllowance mocks base method.
type MockallowanceMockRecorder ¶
type MockallowanceMockRecorder struct {
// contains filtered or unexported fields
}
MockallowanceMockRecorder is the mock recorder for Mockallowance.
func (*MockallowanceMockRecorder) MinerAllowance ¶
func (mr *MockallowanceMockRecorder) MinerAllowance(arg0, arg1 interface{}) *gomock.Call
MinerAllowance indicates an expected call of MinerAllowance.
type MocknonceFetcher ¶
type MocknonceFetcher struct {
// contains filtered or unexported fields
}
MocknonceFetcher is a mock of nonceFetcher interface.
func NewMocknonceFetcher ¶
func NewMocknonceFetcher(ctrl *gomock.Controller) *MocknonceFetcher
NewMocknonceFetcher creates a new mock instance.
func (*MocknonceFetcher) EXPECT ¶
func (m *MocknonceFetcher) EXPECT() *MocknonceFetcherMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MocknonceFetcher) VRFNonce ¶
func (m *MocknonceFetcher) VRFNonce(arg0 types.NodeID, arg1 types.EpochID) (types.VRFPostIndex, error)
VRFNonce mocks base method.
type MocknonceFetcherMockRecorder ¶
type MocknonceFetcherMockRecorder struct {
// contains filtered or unexported fields
}
MocknonceFetcherMockRecorder is the mock recorder for MocknonceFetcher.
func (*MocknonceFetcherMockRecorder) VRFNonce ¶
func (mr *MocknonceFetcherMockRecorder) VRFNonce(arg0, arg1 interface{}) *gomock.Call
VRFNonce indicates an expected call of VRFNonce.
type MockvrfSigner ¶
type MockvrfSigner struct {
// contains filtered or unexported fields
}
MockvrfSigner is a mock of vrfSigner interface.
func NewMockvrfSigner ¶
func NewMockvrfSigner(ctrl *gomock.Controller) *MockvrfSigner
NewMockvrfSigner creates a new mock instance.
func (*MockvrfSigner) EXPECT ¶
func (m *MockvrfSigner) EXPECT() *MockvrfSignerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockvrfSigner) LittleEndian ¶
func (m *MockvrfSigner) LittleEndian() bool
LittleEndian mocks base method.
func (*MockvrfSigner) NodeID ¶
func (m *MockvrfSigner) NodeID() types.NodeID
NodeID mocks base method.
func (*MockvrfSigner) Sign ¶
func (m *MockvrfSigner) Sign(msg []byte) types.VrfSignature
Sign mocks base method.
type MockvrfSignerMockRecorder ¶
type MockvrfSignerMockRecorder struct {
// contains filtered or unexported fields
}
MockvrfSignerMockRecorder is the mock recorder for MockvrfSigner.
func (*MockvrfSignerMockRecorder) LittleEndian ¶
func (mr *MockvrfSignerMockRecorder) LittleEndian() *gomock.Call
LittleEndian indicates an expected call of LittleEndian.
func (*MockvrfSignerMockRecorder) NodeID ¶
func (mr *MockvrfSignerMockRecorder) NodeID() *gomock.Call
NodeID indicates an expected call of NodeID.
func (*MockvrfSignerMockRecorder) Sign ¶
func (mr *MockvrfSignerMockRecorder) Sign(msg interface{}) *gomock.Call
Sign indicates an expected call of Sign.
type MockvrfVerifier ¶
type MockvrfVerifier struct {
// contains filtered or unexported fields
}
MockvrfVerifier is a mock of vrfVerifier interface.
func NewMockvrfVerifier ¶
func NewMockvrfVerifier(ctrl *gomock.Controller) *MockvrfVerifier
NewMockvrfVerifier creates a new mock instance.
func (*MockvrfVerifier) EXPECT ¶
func (m *MockvrfVerifier) EXPECT() *MockvrfVerifierMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockvrfVerifier) Verify ¶
func (m *MockvrfVerifier) Verify(nodeID types.NodeID, msg []byte, sig types.VrfSignature) bool
Verify mocks base method.
type MockvrfVerifierMockRecorder ¶
type MockvrfVerifierMockRecorder struct {
// contains filtered or unexported fields
}
MockvrfVerifierMockRecorder is the mock recorder for MockvrfVerifier.
func (*MockvrfVerifierMockRecorder) Verify ¶
func (mr *MockvrfVerifierMockRecorder) Verify(nodeID, msg, sig interface{}) *gomock.Call
Verify indicates an expected call of Verify.
type OptionFunc ¶
type OptionFunc func(*WeakCoin)
OptionFunc for optional configuration adjustments.
func WithMaxRound ¶
func WithMaxRound(round types.RoundID) OptionFunc
WithMaxRound changes max round.
func WithNextRoundBufferSize ¶
func WithNextRoundBufferSize(size int) OptionFunc
WithNextRoundBufferSize changes size of the buffer for messages from future rounds.
func WithThreshold ¶
func WithThreshold(threshold types.VrfSignature) OptionFunc
WithThreshold changes signature threshold.
type VrfMessage ¶
type VrfMessage struct { Type types.EligibilityType Nonce types.VRFPostIndex Epoch types.EpochID Round types.RoundID Unit uint32 }
func (*VrfMessage) DecodeScale ¶
func (t *VrfMessage) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*VrfMessage) EncodeScale ¶
func (t *VrfMessage) EncodeScale(enc *scale.Encoder) (total int, err error)
type WeakCoin ¶
type WeakCoin struct {
// contains filtered or unexported fields
}
WeakCoin implementation of the protocol.
func New ¶
func New( publisher pubsub.Publisher, signer vrfSigner, verifier vrfVerifier, nonceFetcher nonceFetcher, allowance allowance, msgTime messageTime, opts ...OptionFunc, ) *WeakCoin
New creates an instance of weak coin protocol.
func (*WeakCoin) FinishEpoch ¶
FinishEpoch completes epoch.
func (*WeakCoin) FinishRound ¶
FinishRound computes coinflip based on proposals received in this round. After it is called new proposals for this round won't be accepted.
func (*WeakCoin) Get ¶
func (wc *WeakCoin) Get(ctx context.Context, epoch types.EpochID, round types.RoundID) (bool, error)
Get the result of the coin flip in this round. It is only valid in between StartEpoch/EndEpoch and only after CompleteRound was called.
func (*WeakCoin) HandleProposal ¶
HandleProposal defines method to handle Beacon Weak Coin Messages from gossip.
func (*WeakCoin) StartEpoch ¶
StartEpoch notifies that epoch is started and we can accept messages for this epoch.
func (*WeakCoin) StartRound ¶
StartRound process any buffered messages for this round and broadcast our proposal.