19 #ifndef RIPPLE_TEST_CSF_PEERGROUP_H_INCLUDED
20 #define RIPPLE_TEST_CSF_PEERGROUP_H_INCLUDED
23 #include <test/csf/Peer.h>
24 #include <test/csf/random.h>
172 p->connect(*target, delay);
190 p->disconnect(*target);
226 peer->connect(*to, delay);
266 for (
Peer const* p : t)
297 template <
class RandomNumberDistribution,
class Generator>
303 RandomNumberDistribution sizeDist,
306 assert(peers.
size() == ranks.
size());
324 template <
class RandomNumberDistribution,
class Generator>
330 RandomNumberDistribution sizeDist,
337 for (
auto& peer : peers)
339 for (
auto& target : groups[u(g)])
340 peer->trust(*target);
348 template <
class RandomNumberDistribution,
class Generator>
354 RandomNumberDistribution sizeDist,
362 for (
auto& peer : peers)
364 for (
auto& target : groups[u(g)])
365 peer->connect(*target, delay);
void connectFromTrust(SimDuration delay)
Establish network connections based on trust relations.
bool contains(Peer const *p)
T back_inserter(T... args)
PeerGroup(std::set< Peer * > const &peers)
friend PeerGroup operator-(PeerGroup const &a, PeerGroup const &b)
peers_type::const_reference const_reference
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.
const_iterator begin() const
void connect(PeerGroup const &o, SimDuration delay)
Establish network connection.
peers_type::const_iterator const_iterator
peers_type::reference reference
void trustAndConnect(PeerGroup const &o, SimDuration delay)
Establish trust and network connection.
std::vector< PeerGroup > randomRankedGroups(PeerGroup &peers, std::vector< double > const &ranks, int numGroups, RandomNumberDistribution sizeDist, Generator &g)
Randomly generate peer groups according to ranks.
void randomRankedTrust(PeerGroup &peers, std::vector< double > const &ranks, int numGroups, RandomNumberDistribution sizeDist, Generator &g)
Generate random trust groups based on peer rankings.
PeerGroup(std::vector< Peer * > const &peers)
void trust(PeerGroup const &o)
Establish trust.
const_iterator end() const
PeerGroup(std::vector< Peer * > &&peers)
void disconnect(PeerGroup const &o)
Destroy network connection.
A group of simulation Peers.
A single peer in the simulation.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
const_reference operator[](std::size_t i) const
T set_difference(T... args)
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.
TrustGraph< Peer * > & trustGraph
Handle to Trust graph of network.
typename SimClock::duration SimDuration
peers_type::iterator iterator
friend PeerGroup operator+(PeerGroup const &a, PeerGroup const &b)
void untrust(PeerGroup const &o)
Revoke trust.
friend std::ostream & operator<<(std::ostream &o, PeerGroup const &t)