Kagome
Polkadot Runtime Engine in C++17
kagome::consensus::BabeLotteryImpl Class Reference

#include <babe_lottery_impl.hpp>

Inheritance diagram for kagome::consensus::BabeLotteryImpl:
Collaboration diagram for kagome::consensus::BabeLotteryImpl:

Public Member Functions

 BabeLotteryImpl (std::shared_ptr< crypto::VRFProvider > vrf_provider, std::shared_ptr< consensus::babe::BabeConfigRepository > babe_config_repo, std::shared_ptr< crypto::Hasher > hasher)
 
void changeEpoch (const EpochDescriptor &epoch, const Randomness &randomness, const Threshold &threshold, const crypto::Sr25519Keypair &keypair) override
 
EpochDescriptor getEpoch () const override
 
std::optional< crypto::VRFOutputgetSlotLeadership (primitives::BabeSlotNumber i) const override
 
crypto::VRFOutput slotVrfSignature (primitives::BabeSlotNumber slot) const override
 
std::optional< primitives::AuthorityIndexsecondarySlotAuthor (primitives::BabeSlotNumber slot, primitives::AuthorityListSize authorities_count, const Randomness &randomness) const override
 
- Public Member Functions inherited from kagome::consensus::BabeLottery
virtual ~BabeLottery ()=default
 

Private Attributes

std::shared_ptr< crypto::VRFProvidervrf_provider_
 
std::shared_ptr< crypto::Hasherhasher_
 
log::Logger logger_
 
EpochDescriptor epoch_
 
Randomness randomness_
 
Threshold threshold_
 
crypto::Sr25519Keypair keypair_
 

Detailed Description

Definition at line 24 of file babe_lottery_impl.hpp.

Constructor & Destructor Documentation

kagome::consensus::BabeLotteryImpl::BabeLotteryImpl ( std::shared_ptr< crypto::VRFProvider vrf_provider,
std::shared_ptr< consensus::babe::BabeConfigRepository babe_config_repo,
std::shared_ptr< crypto::Hasher hasher 
)

Definition at line 21 of file babe_lottery_impl.cpp.

Member Function Documentation

void kagome::consensus::BabeLotteryImpl::changeEpoch ( const EpochDescriptor epoch,
const Randomness randomness,
const Threshold threshold,
const crypto::Sr25519Keypair keypair 
)
overridevirtual

Set new epoch and corresponding randomness, threshold and keypair values

Parameters
epochis an information about epoch where we calculate leadership
randomnessis an epoch random byte sequence
thresholdis a maximum value that is considered valid by vrf
keypairis a current babe sign pair

Implements kagome::consensus::BabeLottery.

Definition at line 35 of file babe_lottery_impl.cpp.

EpochDescriptor kagome::consensus::BabeLotteryImpl::getEpoch ( ) const
overridevirtual

Return lottery current epoch

Implements kagome::consensus::BabeLottery.

Definition at line 53 of file babe_lottery_impl.cpp.

std::optional< crypto::VRFOutput > kagome::consensus::BabeLotteryImpl::getSlotLeadership ( primitives::BabeSlotNumber  slot) const
overridevirtual

Compute leadership for the slot

Parameters
slotis a slot number
Returns
none means the peer was not chosen as a leader for that slot, value contains VRF value and proof

Implements kagome::consensus::BabeLottery.

Definition at line 57 of file babe_lottery_impl.cpp.

std::optional< primitives::AuthorityIndex > kagome::consensus::BabeLotteryImpl::secondarySlotAuthor ( primitives::BabeSlotNumber  slot,
primitives::AuthorityListSize  authorities_count,
const Randomness randomness 
) const
overridevirtual

Compute the expected author for secondary slot

Parameters
slot- slot to have secondary block produced
authorities_count- quantity of authorities in current epoch
randomness- current randomness
Returns
- should always return some authority unless authorities list is empty

Implements kagome::consensus::BabeLottery.

Definition at line 94 of file babe_lottery_impl.cpp.

crypto::VRFOutput kagome::consensus::BabeLotteryImpl::slotVrfSignature ( primitives::BabeSlotNumber  slot) const
overridevirtual

Computes VRF proof for the slot regardless threshold. Used when secondary VRF slots are enabled

Parameters
slotis a slot number
Returns
VRF output and proof

Implements kagome::consensus::BabeLottery.

Definition at line 79 of file babe_lottery_impl.cpp.

Member Data Documentation

EpochDescriptor kagome::consensus::BabeLotteryImpl::epoch_
private

Definition at line 55 of file babe_lottery_impl.hpp.

std::shared_ptr<crypto::Hasher> kagome::consensus::BabeLotteryImpl::hasher_
private

Definition at line 51 of file babe_lottery_impl.hpp.

crypto::Sr25519Keypair kagome::consensus::BabeLotteryImpl::keypair_
private

Definition at line 58 of file babe_lottery_impl.hpp.

log::Logger kagome::consensus::BabeLotteryImpl::logger_
private

Definition at line 53 of file babe_lottery_impl.hpp.

Randomness kagome::consensus::BabeLotteryImpl::randomness_
private

Definition at line 56 of file babe_lottery_impl.hpp.

Threshold kagome::consensus::BabeLotteryImpl::threshold_
private

Definition at line 57 of file babe_lottery_impl.hpp.

std::shared_ptr<crypto::VRFProvider> kagome::consensus::BabeLotteryImpl::vrf_provider_
private

Definition at line 50 of file babe_lottery_impl.hpp.


The documentation for this class was generated from the following files: