Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type DB
- type FirstVotingMessage
- type FirstVotingMessageBody
- type FollowingVotingMessage
- type FollowingVotingMessageBody
- type ProposalMessage
- type TortoiseBeacon
- func (tb *TortoiseBeacon) Close()
- func (tb *TortoiseBeacon) GetBeacon(epochID types.EpochID) ([]byte, error)
- func (tb *TortoiseBeacon) HandleSerializedFirstVotingMessage(ctx context.Context, data service.GossipMessage, sync service.Fetcher)
- func (tb *TortoiseBeacon) HandleSerializedFollowingVotingMessage(ctx context.Context, data service.GossipMessage, sync service.Fetcher)
- func (tb *TortoiseBeacon) HandleSerializedProposalMessage(ctx context.Context, data service.GossipMessage, sync service.Fetcher)
- func (tb *TortoiseBeacon) IsClosed() bool
- func (tb *TortoiseBeacon) Start(ctx context.Context) error
Constants ¶
const TBFirstVotingProtocol = "TBFirstVotingGossip"
TBFirstVotingProtocol is a protocol for sending Tortoise Beacon first voting messages through Gossip.
const TBFollowingVotingProtocol = "TBFollowingVotingGossip"
TBFollowingVotingProtocol is a protocol for sending Tortoise Beacon following voting messages through Gossip.
const TBProposalProtocol = "TBProposalGossip"
TBProposalProtocol is a protocol for sending Tortoise Beacon proposal messages through Gossip.
Variables ¶
var ( // ErrMalformedProposal is returned if proposal message is malformed. ErrMalformedProposal = errors.New("malformed proposal message") // ErrProposalDoesntPassThreshold is returned if proposal message doesn't pass threshold. ErrProposalDoesntPassThreshold = errors.New("proposal doesn't pass threshold") // ErrMalformedSignature is returned when signature is malformed. ErrMalformedSignature = errors.New("malformed signature") // ErrAlreadyVoted is returned when miner has already voted. ErrAlreadyVoted = errors.New("already voted") )
var ( ErrBeaconNotCalculated = errors.New("beacon is not calculated for this epoch") ErrZeroEpochWeight = errors.New("zero epoch weight provided") ErrZeroEpoch = errors.New("zero epoch provided") )
Tortoise Beacon errors.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Kappa uint64 `mapstructure:"tortoise-beacon-kappa"` // Security parameter (for calculating ATX threshold) Q *big.Rat `mapstructure:"tortoise-beacon-q"` // Ratio of dishonest spacetime (for calculating ATX threshold). It should be a string representing a rational number. RoundsNumber types.RoundID `mapstructure:"tortoise-beacon-rounds-number"` // Amount of rounds in every epoch GracePeriodDuration time.Duration `mapstructure:"tortoise-beacon-grace-period-duration"` // Grace period duration ProposalDuration time.Duration `mapstructure:"tortoise-beacon-proposal-duration"` // Proposal phase duration FirstVotingRoundDuration time.Duration `mapstructure:"tortoise-beacon-first-voting-round-duration"` // First voting round duration VotingRoundDuration time.Duration `mapstructure:"tortoise-beacon-voting-round-duration"` // Voting round duration WeakCoinRoundDuration time.Duration `mapstructure:"tortoise-beacon-weak-coin-round-duration"` // Weak coin round duration WaitAfterEpochStart time.Duration `mapstructure:"tortoise-beacon-wait-after-epoch-start"` // How long to wait after a new epoch is started. Theta *big.Rat `mapstructure:"tortoise-beacon-theta"` // Ratio of votes for reaching consensus VotesLimit uint64 `mapstructure:"tortoise-beacon-votes-limit"` // Maximum allowed number of votes to be sent }
Config is the configuration of the Tortoise Beacon.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default configuration for the tortoise beacon.
func NodeSimUnitTestConfig ¶
func NodeSimUnitTestConfig() Config
NodeSimUnitTestConfig returns configuration for the tortoise beacon the unit tests with node simulation .
func UnitTestConfig ¶
func UnitTestConfig() Config
UnitTestConfig returns the unit test configuration for the tortoise beacon.
type DB ¶
DB holds beacons for epochs.
func (*DB) GetTortoiseBeacon ¶
GetTortoiseBeacon gets a Tortoise Beacon value for an epoch.
type FirstVotingMessage ¶
type FirstVotingMessage struct { FirstVotingMessageBody Signature []byte }
FirstVotingMessage is a message type which is used when sending first voting messages.
func (FirstVotingMessage) String ¶
func (v FirstVotingMessage) String() string
String returns a string form of FirstVotingMessage.
type FirstVotingMessageBody ¶
FirstVotingMessageBody is FirstVotingMessage without a signature.
type FollowingVotingMessage ¶
type FollowingVotingMessage struct { FollowingVotingMessageBody Signature []byte }
FollowingVotingMessage is a message type which is used when sending following voting messages.
func (FollowingVotingMessage) String ¶
func (v FollowingVotingMessage) String() string
String returns a string form of FollowingVotingMessage.
type FollowingVotingMessageBody ¶
type FollowingVotingMessageBody struct { MinerID types.NodeID RoundID types.RoundID VotesBitVector []uint64 }
FollowingVotingMessageBody is FollowingVotingMessage without a signature.
type ProposalMessage ¶
ProposalMessage is a message type which is used when sending proposals.
func (ProposalMessage) String ¶
func (p ProposalMessage) String() string
String returns a string form of ProposalMessage.
type TortoiseBeacon ¶
TortoiseBeacon represents Tortoise Beacon.
func New ¶
func New( conf Config, layerDuration time.Duration, minerPK *signing.PublicKey, net broadcaster, atxDB activationDB, tortoiseBeaconDB tortoiseBeaconDB, edSigner signing.Signer, edVerifier signing.VerifyExtractor, vrfSigner signing.Signer, vrfVerifier signing.Verifier, weakCoin coin, clock layerClock, logger log.Log, ) *TortoiseBeacon
New returns a new TortoiseBeacon.
func (*TortoiseBeacon) GetBeacon ¶
func (tb *TortoiseBeacon) GetBeacon(epochID types.EpochID) ([]byte, error)
GetBeacon returns a Tortoise Beacon value as []byte for a certain epoch or an error if it doesn't exist. TODO(nkryuchkov): consider not using (using DB instead)
func (*TortoiseBeacon) HandleSerializedFirstVotingMessage ¶
func (tb *TortoiseBeacon) HandleSerializedFirstVotingMessage(ctx context.Context, data service.GossipMessage, sync service.Fetcher)
HandleSerializedFirstVotingMessage defines method to handle Tortoise Beacon first voting Messages from gossip.
func (*TortoiseBeacon) HandleSerializedFollowingVotingMessage ¶
func (tb *TortoiseBeacon) HandleSerializedFollowingVotingMessage(ctx context.Context, data service.GossipMessage, sync service.Fetcher)
HandleSerializedFollowingVotingMessage defines method to handle Tortoise Beacon following voting Messages from gossip.
func (*TortoiseBeacon) HandleSerializedProposalMessage ¶
func (tb *TortoiseBeacon) HandleSerializedProposalMessage(ctx context.Context, data service.GossipMessage, sync service.Fetcher)
HandleSerializedProposalMessage defines method to handle Tortoise Beacon proposal Messages from gossip.
func (*TortoiseBeacon) IsClosed ¶
func (tb *TortoiseBeacon) IsClosed() bool
IsClosed returns true if background workers are not running.