Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type FirstVotingMessage
- type FirstVotingMessageBody
- type FollowingVotingMessage
- type FollowingVotingMessageBody
- type ProposalMessage
- type SyncState
- type TortoiseBeacon
- func (tb *TortoiseBeacon) Close()
- func (tb *TortoiseBeacon) GetBeacon(epochID types.EpochID) ([]byte, error)
- func (tb *TortoiseBeacon) HandleSerializedFirstVotingMessage(ctx context.Context, pid peer.ID, msg []byte) pubsub.ValidationResult
- func (tb *TortoiseBeacon) HandleSerializedFollowingVotingMessage(ctx context.Context, pid peer.ID, msg []byte) pubsub.ValidationResult
- func (tb *TortoiseBeacon) HandleSerializedProposalMessage(ctx context.Context, pid peer.ID, msg []byte) pubsub.ValidationResult
- func (tb *TortoiseBeacon) ReportBeaconFromBlock(epoch types.EpochID, blockID types.BlockID, beacon []byte, weight uint64)
- func (tb *TortoiseBeacon) SetSyncState(sync SyncState)
- 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 ( 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 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 BeaconSyncNumBlocks uint32 `mapstructure:"tortoise-beacon-sync-num-blocks"` // Numbers of layers to wait before determining beacon values from blocks when the node didn't participate in previous epoch. }
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 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 ¶
type FirstVotingMessageBody struct { EpochID types.EpochID ValidProposals [][]byte PotentiallyValidProposals [][]byte }
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 { EpochID types.EpochID 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 ¶
type TortoiseBeacon struct {
// contains filtered or unexported fields
}
TortoiseBeacon represents Tortoise Beacon.
func New ¶
func New( conf Config, nodeID types.NodeID, publisher pubsub.Publisher, atxDB activationDB, edSigner signing.Signer, edVerifier signing.VerifyExtractor, vrfSigner signing.Signer, vrfVerifier signing.Verifier, weakCoin coin, db database.Database, 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, pid peer.ID, msg []byte) pubsub.ValidationResult
HandleSerializedFirstVotingMessage defines method to handle Tortoise Beacon first voting Messages from gossip.
func (*TortoiseBeacon) HandleSerializedFollowingVotingMessage ¶
func (tb *TortoiseBeacon) HandleSerializedFollowingVotingMessage(ctx context.Context, pid peer.ID, msg []byte) pubsub.ValidationResult
HandleSerializedFollowingVotingMessage defines method to handle Tortoise Beacon following voting Messages from gossip.
func (*TortoiseBeacon) HandleSerializedProposalMessage ¶
func (tb *TortoiseBeacon) HandleSerializedProposalMessage(ctx context.Context, pid peer.ID, msg []byte) pubsub.ValidationResult
HandleSerializedProposalMessage defines method to handle Tortoise Beacon proposal Messages from gossip.
func (*TortoiseBeacon) ReportBeaconFromBlock ¶
func (tb *TortoiseBeacon) ReportBeaconFromBlock(epoch types.EpochID, blockID types.BlockID, beacon []byte, weight uint64)
ReportBeaconFromBlock reports the beacon value in a block along with the miner's weight unit.
func (*TortoiseBeacon) SetSyncState ¶
func (tb *TortoiseBeacon) SetSyncState(sync SyncState)
SetSyncState updates sync state provider. Must be executed only once.