rippled
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...

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

Public Member Functions

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

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. More...
 

Private Attributes

hash_map< PublicKey, Slot< clock_type > > slots_
 
SquelchHandler const & handler_
 
Logslogs_
 
const beast::Journal journal_
 

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 46 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 534 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 535 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 540 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 
)
Parameters
appApplicaton reference
handlerSquelch/unsquelch implementation

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

◆ ~Slots()

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

Member Function Documentation

◆ updateSlotAndSquelch()

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.

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

Definition at line 698 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 733 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 573 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 583 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 593 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 603 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 617 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 627 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 725 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 665 of file overlay/Slot.h.

Member Data Documentation

◆ slots_

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

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

◆ handler_

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

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

◆ logs_

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

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

◆ journal_

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

Definition at line 654 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 659 of file overlay/Slot.h.