Documentation ¶
Index ¶
- Constants
- type Message
- type Option
- type UnitAllowances
- type WeakCoin
- func (wc *WeakCoin) FinishEpoch(ctx context.Context, epoch types.EpochID)
- func (wc *WeakCoin) FinishRound(ctx context.Context)
- func (wc *WeakCoin) Get(ctx context.Context, epoch types.EpochID, round types.RoundID) bool
- func (wc *WeakCoin) HandleProposal(ctx context.Context, pid peer.ID, msg []byte) pubsub.ValidationResult
- func (wc *WeakCoin) StartEpoch(ctx context.Context, epoch types.EpochID, allowances UnitAllowances)
- func (wc *WeakCoin) StartRound(ctx context.Context, round types.RoundID) error
Constants ¶
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 WithNextRoundBufferSize ¶
WithNextRoundBufferSize changes size of the buffer for messages from future rounds.
func WithThreshold ¶
WithThreshold changes signature threshold.
type UnitAllowances ¶
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 ¶
FinishEpoch completes epoch. After it is called Get for this epoch will panic.
func (*WeakCoin) FinishRound ¶
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 ¶
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 ¶
StartEpoch notifies that epoch is started and we can accept messages for this epoch.