rippled
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ripple::reduce_relay::Slots< clock_type > Class Template Reference

Slots is a container for validator's Slot and handles Slot update when a message is received from a validator. More...

#include <Slot.h>

Collaboration diagram for ripple::reduce_relay::Slots< clock_type >:
Collaboration graph
[legend]

Public Member Functions

 Slots (Logs &logs, SquelchHandler const &handler, Config const &config)
 
 ~Slots ()=default
 
bool baseSquelchReady ()
 Check if base squelching feature is enabled and ready.
 
bool reduceRelayReady ()
 Check if reduce_relay::WAIT_ON_BOOTUP time passed since startup.
 
void updateSlotAndSquelch (uint256 const &key, PublicKey const &validator, id_t id, protocol::MessageType type)
 Calls Slot::update of Slot associated with the validator, with a noop callback.
 
void updateSlotAndSquelch (uint256 const &key, PublicKey const &validator, id_t id, protocol::MessageType type, typename Slot< clock_type >::ignored_squelch_callback callback)
 Calls Slot::update of Slot associated with the validator.
 
void deleteIdlePeers ()
 Check if peers stopped relaying messages and if slots stopped receiving messages from the validator.
 
std::optional< std::uint16_tinState (PublicKey const &validator, PeerState state) const
 Return number of peers in state.
 
std::optional< std::uint16_tnotInState (PublicKey const &validator, PeerState state) const
 Return number of peers not in state.
 
bool inState (PublicKey const &validator, SlotState state) const
 Return true if Slot is in state.
 
std::set< id_tgetSelected (PublicKey const &validator)
 Get selected peers.
 
std::unordered_map< typename Peer::id_t, std::tuple< PeerState, uint16_t, uint32_t, std::uint32_t > > getPeers (PublicKey const &validator)
 Get peers info.
 
std::optional< SlotStategetState (PublicKey const &validator)
 Get Slot's state.
 
void deletePeer (id_t id, bool erase)
 Called when a peer is deleted.
 

Private Types

using time_point = typename clock_type::time_point
 
using id_t = typename Peer::id_t
 
using messages = beast::aged_unordered_map< uint256, std::unordered_set< Peer::id_t >, clock_type, hardened_hash< strong_hash > >
 

Private Member Functions

bool addPeerMessage (uint256 const &key, id_t id)
 Add message/peer if have not seen this message from the peer.
 

Private Attributes

std::atomic_bool reduceRelayReady_ {false}
 
hash_map< PublicKey, Slot< clock_type > > slots_
 
SquelchHandler const & handler_
 
Logslogs_
 
beast::Journal const journal_
 
bool const baseSquelchEnabled_
 
uint16_t const maxSelectedPeers_
 

Static Private Attributes

static messages peersWithMessage_
 

Detailed Description

template<typename clock_type>
class ripple::reduce_relay::Slots< clock_type >

Slots is a container for validator's Slot and handles Slot update when a message is received from a validator.

It also handles Slot aging and checks for peers which are disconnected or stopped relaying the messages.

Definition at line 550 of file overlay/Slot.h.

Member Typedef Documentation

◆ time_point

template<typename clock_type >
using ripple::reduce_relay::Slots< clock_type >::time_point = typename clock_type::time_point
private

Definition at line 552 of file overlay/Slot.h.

◆ id_t

template<typename clock_type >
using ripple::reduce_relay::Slots< clock_type >::id_t = typename Peer::id_t
private

Definition at line 553 of file overlay/Slot.h.

◆ messages

template<typename clock_type >
using ripple::reduce_relay::Slots< clock_type >::messages = beast::aged_unordered_map< uint256, std::unordered_set<Peer::id_t>, clock_type, hardened_hash<strong_hash> >
private

Definition at line 554 of file overlay/Slot.h.

Constructor & Destructor Documentation

◆ Slots()

template<typename clock_type >
ripple::reduce_relay::Slots< clock_type >::Slots ( Logs logs,
SquelchHandler const &  handler,
Config const &  config 
)
Parameters
logsreference to the logger
handlerSquelch/unsquelch implementation
configreference to the global config

Definition at line 566 of file overlay/Slot.h.

◆ ~Slots()

template<typename clock_type >
ripple::reduce_relay::Slots< clock_type >::~Slots ( )
default

Member Function Documentation

◆ baseSquelchReady()

template<typename clock_type >
bool ripple::reduce_relay::Slots< clock_type >::baseSquelchReady ( )

Check if base squelching feature is enabled and ready.

Definition at line 578 of file overlay/Slot.h.

◆ reduceRelayReady()

template<typename clock_type >
bool ripple::reduce_relay::Slots< clock_type >::reduceRelayReady ( )

Check if reduce_relay::WAIT_ON_BOOTUP time passed since startup.

Definition at line 585 of file overlay/Slot.h.

◆ updateSlotAndSquelch() [1/2]

template<typename clock_type >
void ripple::reduce_relay::Slots< clock_type >::updateSlotAndSquelch ( uint256 const &  key,
PublicKey const &  validator,
id_t  id,
protocol::MessageType  type 
)

Calls Slot::update of Slot associated with the validator, with a noop callback.

Parameters
keyMessage's hash
validatorValidator's public key
idPeer's id which received the message
typeReceived protocol message type

Definition at line 603 of file overlay/Slot.h.

◆ updateSlotAndSquelch() [2/2]

template<typename clock_type >
void ripple::reduce_relay::Slots< clock_type >::updateSlotAndSquelch ( uint256 const &  key,
PublicKey const &  validator,
id_t  id,
protocol::MessageType  type,
typename Slot< clock_type >::ignored_squelch_callback  callback 
)

Calls Slot::update of Slot associated with the validator.

Parameters
keyMessage's hash
validatorValidator's public key
idPeer's id which received the message
typeReceived protocol message type
callbackA callback to report ignored validations

Definition at line 766 of file overlay/Slot.h.

◆ deleteIdlePeers()

template<typename clock_type >
void ripple::reduce_relay::Slots< clock_type >::deleteIdlePeers ( )

Check if peers stopped relaying messages and if slots stopped receiving messages from the validator.

Definition at line 804 of file overlay/Slot.h.

◆ inState() [1/2]

template<typename clock_type >
std::optional< std::uint16_t > ripple::reduce_relay::Slots< clock_type >::inState ( PublicKey const &  validator,
PeerState  state 
) const

Return number of peers in state.

Definition at line 635 of file overlay/Slot.h.

◆ notInState()

template<typename clock_type >
std::optional< std::uint16_t > ripple::reduce_relay::Slots< clock_type >::notInState ( PublicKey const &  validator,
PeerState  state 
) const

Return number of peers not in state.

Definition at line 645 of file overlay/Slot.h.

◆ inState() [2/2]

template<typename clock_type >
bool ripple::reduce_relay::Slots< clock_type >::inState ( PublicKey const &  validator,
SlotState  state 
) const

Return true if Slot is in state.

Definition at line 655 of file overlay/Slot.h.

◆ getSelected()

template<typename clock_type >
std::set< id_t > ripple::reduce_relay::Slots< clock_type >::getSelected ( PublicKey const &  validator)

Get selected peers.

Definition at line 665 of file overlay/Slot.h.

◆ getPeers()

template<typename clock_type >
std::unordered_map< typename Peer::id_t, std::tuple< PeerState, uint16_t, uint32_t, std::uint32_t > > ripple::reduce_relay::Slots< clock_type >::getPeers ( PublicKey const &  validator)

Get peers info.

Return map of peer's state, count, and squelch expiration milliseconds.

Definition at line 679 of file overlay/Slot.h.

◆ getState()

template<typename clock_type >
std::optional< SlotState > ripple::reduce_relay::Slots< clock_type >::getState ( PublicKey const &  validator)

Get Slot's state.

Definition at line 689 of file overlay/Slot.h.

◆ deletePeer()

template<typename clock_type >
void ripple::reduce_relay::Slots< clock_type >::deletePeer ( id_t  id,
bool  erase 
)

Called when a peer is deleted.

If the peer was selected to be the source of messages from the validator then squelched peers have to be unsquelched.

Parameters
idPeer's id
eraseIf true then erase the peer

Definition at line 796 of file overlay/Slot.h.

◆ addPeerMessage()

template<typename clock_type >
bool ripple::reduce_relay::Slots< clock_type >::addPeerMessage ( uint256 const &  key,
id_t  id 
)
private

Add message/peer if have not seen this message from the peer.

A message is aged after IDLED seconds. Return true if added

Definition at line 733 of file overlay/Slot.h.

Member Data Documentation

◆ reduceRelayReady_

template<typename clock_type >
std::atomic_bool ripple::reduce_relay::Slots< clock_type >::reduceRelayReady_ {false}
private

Definition at line 713 of file overlay/Slot.h.

◆ slots_

template<typename clock_type >
hash_map<PublicKey, Slot<clock_type> > ripple::reduce_relay::Slots< clock_type >::slots_
private

Definition at line 715 of file overlay/Slot.h.

◆ handler_

template<typename clock_type >
SquelchHandler const& ripple::reduce_relay::Slots< clock_type >::handler_
private

Definition at line 716 of file overlay/Slot.h.

◆ logs_

template<typename clock_type >
Logs& ripple::reduce_relay::Slots< clock_type >::logs_
private

Definition at line 717 of file overlay/Slot.h.

◆ journal_

template<typename clock_type >
beast::Journal const ripple::reduce_relay::Slots< clock_type >::journal_
private

Definition at line 718 of file overlay/Slot.h.

◆ baseSquelchEnabled_

template<typename clock_type >
bool const ripple::reduce_relay::Slots< clock_type >::baseSquelchEnabled_
private

Definition at line 720 of file overlay/Slot.h.

◆ maxSelectedPeers_

template<typename clock_type >
uint16_t const ripple::reduce_relay::Slots< clock_type >::maxSelectedPeers_
private

Definition at line 721 of file overlay/Slot.h.

◆ peersWithMessage_

template<typename clock_type >
messages ripple::reduce_relay::Slots< clock_type >::peersWithMessage_
staticprivate
Initial value:
{
beast::get_abstract_clock<clock_type>()}

Definition at line 727 of file overlay/Slot.h.