weakcoin

package
v0.2.21-beta.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 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      uint64
	MinerPK   []byte
	Signature []byte
}

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

func (m *MockvrfSigner) PublicKey() *signing.PublicKey

PublicKey mocks base method.

func (*MockvrfSigner) Sign

func (m *MockvrfSigner) Sign(msg []byte) []byte

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

func (mr *MockvrfSignerMockRecorder) PublicKey() *gomock.Call

PublicKey indicates an expected call of PublicKey.

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, sig []byte) 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 []byte) OptionFunc

WithThreshold changes signature threshold.

type UnitAllowances

type UnitAllowances map[string]uint64

UnitAllowances is a map from miner identifier to the number of units of spacetime.

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,
	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. After it is called Get for this epoch will panic.

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

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) pubsub.ValidationResult

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

func (*WeakCoin) StartEpoch

func (wc *WeakCoin) StartEpoch(ctx context.Context, epoch types.EpochID, nonce types.VRFPostIndex, allowances UnitAllowances)

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

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

type WeakCoinVrfMessage

type WeakCoinVrfMessage struct {
	Prefix string
	Epoch  types.EpochID
	Nonce  types.VRFPostIndex
	Round  types.RoundID
	Unit   uint64
}

func (*WeakCoinVrfMessage) DecodeScale

func (t *WeakCoinVrfMessage) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*WeakCoinVrfMessage) EncodeScale

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

Jump to

Keyboard shortcuts

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