weakcoin

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: MIT Imports: 14 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 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

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

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

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 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 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,
	signer vrfSigner,
	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, nonce *types.VRFPostIndex)

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