20 #ifndef RIPPLE_TEST_CSF_BASICNETWORK_H_INCLUDED
21 #define RIPPLE_TEST_CSF_BASICNETWORK_H_INCLUDED
23 #include <test/csf/Digraph.h>
24 #include <test/csf/Scheduler.h>
176 template <
class Function>
187 return links_.outEdges(from);
199 template <
class Peer>
204 template <
class Peer>
214 if (!links_.
connect(from, to, link_type{false, delay, now}))
216 auto const result = links_.
connect(to, from, link_type{
true, delay, now});
222 template <
class Peer>
234 template <
class Peer>
235 template <
class Function>
239 auto link = links_.
edge(from, to);
244 link->delay, [from, to, sent, f = std::forward<Function>(f),
this] {
247 if (auto l = links_.edge(from, to); l && l->established <= sent)
bool disconnect(Peer const &peer1, Peer const &peer2)
Break a link.
Digraph< Peer, link_type > const & graph() const
Return the underlying digraph.
Simulated discrete-event scheduler.
typename clock_type::duration duration
cancel_token in(duration const &delay, Function &&f)
Schedule an event after a specified duration passes.
bool disconnect(Vertex source, Vertex target)
Disconnect two vertices.
typename clock_type::time_point time_point
bool connect(Peer const &from, Peer const &to, duration const &delay=std::chrono::seconds{0})
Connect two peers.
BasicNetwork(BasicNetwork const &)=delete
Digraph< Peer, link_type > links_
A single peer in the simulation.
std::optional< EdgeData > edge(Vertex source, Vertex target) const
Return edge data between two vertices.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
beast::manual_clock< std::chrono::steady_clock > clock_type
void send(Peer const &from, Peer const &to, Function &&f)
Send a message to a peer.
bool connect(Vertex source, Vertex target, EdgeData e)
Connect two vertices.
auto links(Peer const &from)
Return the range of active links.
time_point now() const
Return the current network time.
BasicNetwork & operator=(BasicNetwork const &)=delete
typename std::chrono::steady_clock ::time_point time_point
Peer to peer network simulator.
typename std::chrono::steady_clock ::duration duration
link_type(bool inbound_, duration delay_, time_point established_)