weakcoin

package
v0.2.1-beta.8 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// GossipProtocol is weak coin Gossip protocol name.
	GossipProtocol = "WeakCoinGossip"
)

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.

type Option

type Option func(*WeakCoin)

Option for optional configuration adjustments.

func WithLog

func WithLog(logger log.Log) Option

WithLog changes logger.

func WithMaxRound

func WithMaxRound(round types.RoundID) Option

WithMaxRound changes max round.

func WithNextRoundBufferSize

func WithNextRoundBufferSize(size int) Option

WithNextRoundBufferSize changes size of the buffer for messages from future rounds.

func WithThreshold

func WithThreshold(threshold []byte) Option

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(
	net broadcaster,
	signer signing.Signer,
	verifier signing.Verifier,
	opts ...Option,
) *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) HandleSerializedMessage

func (wc *WeakCoin) HandleSerializedMessage(ctx context.Context, data service.GossipMessage, _ service.Fetcher)

HandleSerializedMessage defines method to handle Tortoise Beacon Weak Coin Messages from gossip.

func (*WeakCoin) StartEpoch

func (wc *WeakCoin) StartEpoch(ctx context.Context, epoch types.EpochID, 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.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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