Back to Site
Loading...
Searching...
No Matches
librats::ReconnectionService Class Referencefinal

#include <reconnection.h>

Inheritance diagram for librats::ReconnectionService:
[legend]
Collaboration diagram for librats::ReconnectionService:
[legend]

Classes

struct  Config

Public Member Functions

 ReconnectionService ()
 ReconnectionService (Config config)
 ~ReconnectionService () override
void add (const Address &address)
 Register an address to keep connected. Persists it if a store is configured.
void remove (const Address &address)
 Stop reconnecting to an address: drops it as a target and from the store.
size_t target_count () const
std::vector< Address > known_peers (size_t n) const
 The passive reserve pool: up to n best-known peer addresses from the book (history of everyone we have connected to), most promising first.
std::vector< PeerId > lost_peers () const
 The peers lost and being dialed again (Config::lost_for), until each is back or given up on.
void on_given_up (std::function< void(const PeerId &)> handler)
 Called for a lost peer not back within Config::lost_for, on the service's thread.
void attach (NodeContext &ctx) override
void start () override
void stop () override
Public Member Functions inherited from librats::Subsystem
virtual ~Subsystem ()=default

Static Public Member Functions

static bool lost (CloseReason reason) noexcept
 Whether a connection that closed for reason was lost rather than ended: neither side closed it — the peer went quiet past the idle deadline or stopped answering.

Detailed Description

Definition at line 53 of file reconnection.h.

Constructor & Destructor Documentation

◆ ReconnectionService() [1/2]

librats::ReconnectionService::ReconnectionService ( )

◆ ReconnectionService() [2/2]

librats::ReconnectionService::ReconnectionService ( Config config)
explicit

◆ ~ReconnectionService()

librats::ReconnectionService::~ReconnectionService ( )
override

Member Function Documentation

◆ add()

void librats::ReconnectionService::add ( const Address & address)

Register an address to keep connected. Persists it if a store is configured.

◆ attach()

void librats::ReconnectionService::attach ( NodeContext & ctx)
overridevirtual

Implements librats::Subsystem.

◆ known_peers()

std::vector< Address > librats::ReconnectionService::known_peers ( size_t n) const

The passive reserve pool: up to n best-known peer addresses from the book (history of everyone we have connected to), most promising first.

Not dialed automatically beyond the startup seed — exposed for the app / discovery to use as a bootstrap source when peer count is low.

◆ lost()

bool librats::ReconnectionService::lost ( CloseReason reason)
inlinestaticnoexcept

Whether a connection that closed for reason was lost rather than ended: neither side closed it — the peer went quiet past the idle deadline or stopped answering.

Definition at line 73 of file reconnection.h.

Referenced by stop().

◆ lost_peers()

std::vector< PeerId > librats::ReconnectionService::lost_peers ( ) const

The peers lost and being dialed again (Config::lost_for), until each is back or given up on.

◆ on_given_up()

void librats::ReconnectionService::on_given_up ( std::function< void(const PeerId &)> handler)

Called for a lost peer not back within Config::lost_for, on the service's thread.

Set before start().

◆ remove()

void librats::ReconnectionService::remove ( const Address & address)

Stop reconnecting to an address: drops it as a target and from the store.

Use when the application intentionally parts with a peer and does not want it re-dialed. (A later fresh connection to it may re-learn it if persist_discovered is on.)

◆ start()

void librats::ReconnectionService::start ( )
overridevirtual

Implements librats::Subsystem.

◆ stop()

void librats::ReconnectionService::stop ( )
overridevirtual

Implements librats::Subsystem.

References lost().

◆ target_count()

size_t librats::ReconnectionService::target_count ( ) const

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