weakcoin

package
v0.2.12-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: MIT Imports: 11 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(
	publisher pubsub.Publisher,
	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) HandleProposal

func (wc *WeakCoin) HandleProposal(ctx context.Context, pid peer.ID, msg []byte) pubsub.ValidationResult

HandleProposal 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.

Jump to

Keyboard shortcuts

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