rippled
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
xrpl::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 xrpl::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_ {beast::get_abstract_clock<clock_type>()}
 

Detailed Description

template<typename clock_type>
class xrpl::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 511 of file overlay/Slot.h.

Member Typedef Documentation

◆ time_point

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

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

◆ id_t

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

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

◆ messages

template<typename clock_type >
using xrpl::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 515 of file overlay/Slot.h.

Constructor & Destructor Documentation

◆ Slots()

template<typename clock_type >
xrpl::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 524 of file overlay/Slot.h.

◆ ~Slots()

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

Member Function Documentation

◆ baseSquelchReady()

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

Check if base squelching feature is enabled and ready.

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

◆ reduceRelayReady()

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

Check if reduce_relay::WAIT_ON_BOOTUP time passed since startup.

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

◆ updateSlotAndSquelch() [1/2]

template<typename clock_type >
void xrpl::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 560 of file overlay/Slot.h.

◆ updateSlotAndSquelch() [2/2]

template<typename clock_type >
void xrpl::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 713 of file overlay/Slot.h.

◆ deleteIdlePeers()

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

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

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

◆ inState() [1/2]

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

Return number of peers in state.

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

◆ notInState()

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

Return number of peers not in state.

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

◆ inState() [2/2]

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

Return true if Slot is in state.

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

◆ getSelected()

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

Get selected peers.

Definition at line 618 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 > > xrpl::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 630 of file overlay/Slot.h.

◆ getState()

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

Get Slot's state.

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

◆ deletePeer()

template<typename clock_type >
void xrpl::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 739 of file overlay/Slot.h.

◆ addPeerMessage()

template<typename clock_type >
bool xrpl::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 683 of file overlay/Slot.h.

Member Data Documentation

◆ reduceRelayReady_

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

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

◆ slots_

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

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

◆ handler_

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

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

◆ logs_

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

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

◆ journal_

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

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

◆ baseSquelchEnabled_

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

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

◆ maxSelectedPeers_

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

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

◆ peersWithMessage_

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

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