weakcoin

package
v1.6.0-alpha.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package weakcoin is a generated GoMock package.

nolint

Index

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 (t *Message) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*Message) EncodeScale

func (t *Message) EncodeScale(enc *scale.Encoder) (total int, err error)

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

EXPECT returns an object that allows the caller to indicate expected use.

func (*Mockallowance) MinerAllowance

func (m *Mockallowance) MinerAllowance(arg0 types.EpochID, arg1 types.NodeID) uint32

MinerAllowance mocks base method.

type MockallowanceMinerAllowanceCall added in v1.4.0

type MockallowanceMinerAllowanceCall struct {
	*gomock.Call
}

MockallowanceMinerAllowanceCall wrap *gomock.Call

func (*MockallowanceMinerAllowanceCall) Do added in v1.4.0

Do rewrite *gomock.Call.Do

func (*MockallowanceMinerAllowanceCall) DoAndReturn added in v1.4.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockallowanceMinerAllowanceCall) Return added in v1.4.0

Return rewrite *gomock.Call.Return

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 any) *MockallowanceMinerAllowanceCall

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

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

VRFNonce indicates an expected call of VRFNonce.

type MocknonceFetcherVRFNonceCall added in v1.4.0

type MocknonceFetcherVRFNonceCall struct {
	*gomock.Call
}

MocknonceFetcherVRFNonceCall wrap *gomock.Call

func (*MocknonceFetcherVRFNonceCall) Do added in v1.4.0

Do rewrite *gomock.Call.Do

func (*MocknonceFetcherVRFNonceCall) DoAndReturn added in v1.4.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MocknonceFetcherVRFNonceCall) Return added in v1.4.0

Return rewrite *gomock.Call.Return

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

EXPECT returns an object that allows the caller to indicate expected use.

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) NodeID

NodeID indicates an expected call of NodeID.

func (*MockvrfSignerMockRecorder) Sign

Sign indicates an expected call of Sign.

type MockvrfSignerNodeIDCall added in v1.4.0

type MockvrfSignerNodeIDCall struct {
	*gomock.Call
}

MockvrfSignerNodeIDCall wrap *gomock.Call

func (*MockvrfSignerNodeIDCall) Do added in v1.4.0

Do rewrite *gomock.Call.Do

func (*MockvrfSignerNodeIDCall) DoAndReturn added in v1.4.0

func (c *MockvrfSignerNodeIDCall) DoAndReturn(f func() types.NodeID) *MockvrfSignerNodeIDCall

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockvrfSignerNodeIDCall) Return added in v1.4.0

Return rewrite *gomock.Call.Return

type MockvrfSignerSignCall added in v1.4.0

type MockvrfSignerSignCall struct {
	*gomock.Call
}

MockvrfSignerSignCall wrap *gomock.Call

func (*MockvrfSignerSignCall) Do added in v1.4.0

Do rewrite *gomock.Call.Do

func (*MockvrfSignerSignCall) DoAndReturn added in v1.4.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockvrfSignerSignCall) Return added in v1.4.0

Return rewrite *gomock.Call.Return

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

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 any) *MockvrfVerifierVerifyCall

Verify indicates an expected call of Verify.

type MockvrfVerifierVerifyCall added in v1.4.0

type MockvrfVerifierVerifyCall struct {
	*gomock.Call
}

MockvrfVerifierVerifyCall wrap *gomock.Call

func (*MockvrfVerifierVerifyCall) Do added in v1.4.0

Do rewrite *gomock.Call.Do

func (*MockvrfVerifierVerifyCall) DoAndReturn added in v1.4.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockvrfVerifierVerifyCall) Return added in v1.4.0

Return rewrite *gomock.Call.Return

type OptionFunc

type OptionFunc func(*WeakCoin)

OptionFunc for optional configuration adjustments.

func WithLog

func WithLog(logger log.Log) OptionFunc

WithLog changes logger.

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 Participant added in v1.3.0

type Participant struct {
	Signer vrfSigner
	Nonce  types.VRFPostIndex
}

type VrfMessage

type VrfMessage struct {
	Type  types.EligibilityType // always types.EligibilityBeaconWC
	Nonce types.VRFPostIndex
	Epoch types.EpochID
	Round types.RoundID
	Unit  uint32
}

VrfMessage is the payload for the signature of `Message`.

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,
	verifier vrfVerifier,
	nonceFetcher nonceFetcher,
	allowance allowance,
	msgTime messageTime,
	opts ...OptionFunc,
) *WeakCoin

New creates an instance of weak coin protocol.

func (*WeakCoin) FinishEpoch

func (wc *WeakCoin) FinishEpoch(ctx context.Context, epoch types.EpochID)

FinishEpoch completes epoch.

func (*WeakCoin) FinishRound

func (wc *WeakCoin) FinishRound(ctx context.Context)

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

func (wc *WeakCoin) HandleProposal(ctx context.Context, peer p2p.Peer, msg []byte) error

HandleProposal defines method to handle Beacon Weak Coin Messages from gossip.

func (*WeakCoin) StartEpoch

func (wc *WeakCoin) StartEpoch(ctx context.Context, epoch types.EpochID)

StartEpoch notifies that epoch is started and we can accept messages for this epoch.

func (*WeakCoin) StartRound

func (wc *WeakCoin) StartRound(ctx context.Context, round types.RoundID, participants []Participant)

StartRound process any buffered messages for this round and broadcast our proposal.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL