1#ifndef XRPL_TEST_CSF_PEERGROUP_H_INCLUDED
2#define XRPL_TEST_CSF_PEERGROUP_H_INCLUDED
4#include <test/csf/Peer.h>
5#include <test/csf/random.h>
155 p->connect(*target, delay);
173 p->disconnect(*target);
207 for (
Peer* to : peer->trustGraph.trustedPeers(peer))
209 peer->connect(*to, delay);
249 for (
Peer const* p : t)
280template <
class RandomNumberDistribution,
class Generator>
286 RandomNumberDistribution sizeDist,
289 assert(peers.
size() == ranks.
size());
307template <
class RandomNumberDistribution,
class Generator>
313 RandomNumberDistribution sizeDist,
320 for (
auto& peer : peers)
322 for (
auto& target : groups[u(g)])
323 peer->trust(*target);
331template <
class RandomNumberDistribution,
class Generator>
337 RandomNumberDistribution sizeDist,
345 for (
auto& peer : peers)
347 for (
auto& target : groups[u(g)])
348 peer->connect(*target, delay);
T back_inserter(T... args)
A group of simulation Peers.
bool contains(Peer const *p)
PeerGroup(std::vector< Peer * > &&peers)
friend PeerGroup operator+(PeerGroup const &a, PeerGroup const &b)
peers_type::const_iterator const_iterator
peers_type::reference reference
PeerGroup(std::set< Peer * > const &peers)
const_iterator begin() const
PeerGroup(std::vector< Peer * > const &peers)
void trust(PeerGroup const &o)
Establish trust.
void trustAndConnect(PeerGroup const &o, SimDuration delay)
Establish trust and network connection.
void disconnect(PeerGroup const &o)
Destroy network connection.
friend std::ostream & operator<<(std::ostream &o, PeerGroup const &t)
peers_type::const_reference const_reference
void connectFromTrust(SimDuration delay)
Establish network connections based on trust relations.
const_iterator end() const
peers_type::iterator iterator
void untrust(PeerGroup const &o)
Revoke trust.
const_reference operator[](std::size_t i) const
friend PeerGroup operator-(PeerGroup const &a, PeerGroup const &b)
void connect(PeerGroup const &o, SimDuration delay)
Establish network connection.
void randomRankedConnect(PeerGroup &peers, std::vector< double > const &ranks, int numGroups, RandomNumberDistribution sizeDist, Generator &g, SimDuration delay)
Generate random network groups based on peer rankings.
typename SimClock::duration SimDuration
void randomRankedTrust(PeerGroup &peers, std::vector< double > const &ranks, int numGroups, RandomNumberDistribution sizeDist, Generator &g)
Generate random trust groups based on peer rankings.
std::vector< T > random_weighted_shuffle(std::vector< T > v, std::vector< double > w, G &g)
Return a randomly shuffled copy of vector based on weights w.
std::vector< PeerGroup > randomRankedGroups(PeerGroup &peers, std::vector< double > const &ranks, int numGroups, RandomNumberDistribution sizeDist, Generator &g)
Randomly generate peer groups according to ranks.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
T set_difference(T... args)
A single peer in the simulation.