TARAXA
taraxa::network::tarcap::PbftSyncingState Class Reference

PbftSyncingState contains common members and functions related to syncing that are shared among multiple classes. More...

#include <pbft_syncing_state.hpp>

Public Member Functions

 PbftSyncingState (uint16_t deep_syncing_threshold)
 
bool setPbftSyncing (bool syncing, PbftPeriod current_period=0, std::shared_ptr< TaraxaPeer > peer=nullptr)
 Set pbft syncing. More...
 
void setSyncStatePeriod (PbftPeriod period)
 Set current pbft period. More...
 
bool isDeepPbftSyncing () const
 Check if PBFT is in deep syncing. More...
 
bool isPbftSyncing ()
 Check if PBFT is in syncing. If not in active syncing, set PBFT syncing to false. More...
 
std::shared_ptr< TaraxaPeersyncingPeer () const
 Get the peer that our node is syncing with. More...
 
void setLastSyncPacketTime ()
 Set current time as last received sync packet time. More...
 
bool isActivelySyncing () const
 Check if syncing is active. More...
 

Private Attributes

std::atomic< bool > deep_pbft_syncing_ {false}
 
std::atomic< bool > pbft_syncing_ {false}
 
const uint16_t kDeepSyncingThreshold
 
std::chrono::steady_clock::time_point last_received_sync_packet_time_ {std::chrono::steady_clock::now()}
 
std::shared_mutex time_mutex_
 
std::shared_ptr< TaraxaPeerpeer_
 
std::shared_mutex peer_mutex_
 

Static Private Attributes

static constexpr std::chrono::seconds kSyncingInactivityThreshold {60}
 

Detailed Description

PbftSyncingState contains common members and functions related to syncing that are shared among multiple classes.

Constructor & Destructor Documentation

◆ PbftSyncingState()

taraxa::network::tarcap::PbftSyncingState::PbftSyncingState ( uint16_t  deep_syncing_threshold)

Member Function Documentation

◆ isActivelySyncing()

bool taraxa::network::tarcap::PbftSyncingState::isActivelySyncing ( ) const

Check if syncing is active.

Returns
true if last syncing packet was received within kSyncingInactivityThreshold

◆ isDeepPbftSyncing()

bool taraxa::network::tarcap::PbftSyncingState::isDeepPbftSyncing ( ) const

Check if PBFT is in deep syncing.

Returns
true if PBFT is in deep syncing

◆ isPbftSyncing()

bool taraxa::network::tarcap::PbftSyncingState::isPbftSyncing ( )

Check if PBFT is in syncing. If not in active syncing, set PBFT syncing to false.

Returns
true if PBFT is in syncing

◆ setLastSyncPacketTime()

void taraxa::network::tarcap::PbftSyncingState::setLastSyncPacketTime ( )

Set current time as last received sync packet time.

◆ setPbftSyncing()

bool taraxa::network::tarcap::PbftSyncingState::setPbftSyncing ( bool  syncing,
PbftPeriod  current_period = 0,
std::shared_ptr< TaraxaPeer peer = nullptr 
)

Set pbft syncing.

Parameters
syncing
current_period
peerused in case syncing flag == true to set which peer is the node syncing with

◆ setSyncStatePeriod()

void taraxa::network::tarcap::PbftSyncingState::setSyncStatePeriod ( PbftPeriod  period)

Set current pbft period.

◆ syncingPeer()

std::shared_ptr< TaraxaPeer > taraxa::network::tarcap::PbftSyncingState::syncingPeer ( ) const

Get the peer that our node is syncing with.

Returns
syncing peer, in case there is none - nullptr is returned

Member Data Documentation

◆ deep_pbft_syncing_

std::atomic<bool> taraxa::network::tarcap::PbftSyncingState::deep_pbft_syncing_ {false}
private

◆ kDeepSyncingThreshold

const uint16_t taraxa::network::tarcap::PbftSyncingState::kDeepSyncingThreshold
private

◆ kSyncingInactivityThreshold

constexpr std::chrono::seconds taraxa::network::tarcap::PbftSyncingState::kSyncingInactivityThreshold {60}
staticconstexprprivate

◆ last_received_sync_packet_time_

std::chrono::steady_clock::time_point taraxa::network::tarcap::PbftSyncingState::last_received_sync_packet_time_ {std::chrono::steady_clock::now()}
private

◆ pbft_syncing_

std::atomic<bool> taraxa::network::tarcap::PbftSyncingState::pbft_syncing_ {false}
private

◆ peer_

std::shared_ptr<TaraxaPeer> taraxa::network::tarcap::PbftSyncingState::peer_
private

◆ peer_mutex_

std::shared_mutex taraxa::network::tarcap::PbftSyncingState::peer_mutex_
mutableprivate

◆ time_mutex_

std::shared_mutex taraxa::network::tarcap::PbftSyncingState::time_mutex_
mutableprivate

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