19#ifndef RIPPLE_TEST_CSF_PEERGROUP_H_INCLUDED
20#define RIPPLE_TEST_CSF_PEERGROUP_H_INCLUDED
22#include <test/csf/Peer.h>
23#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)
297template <
class RandomNumberDistribution,
class Generator>
303 RandomNumberDistribution sizeDist,
306 assert(peers.
size() == ranks.
size());
324template <
class RandomNumberDistribution,
class Generator>
330 RandomNumberDistribution sizeDist,
337 for (
auto& peer : peers)
339 for (
auto& target : groups[u(g)])
340 peer->trust(*target);
348template <
class RandomNumberDistribution,
class Generator>
354 RandomNumberDistribution sizeDist,
362 for (
auto& peer : peers)
364 for (
auto& target : groups[u(g)])
365 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.
TrustGraph< Peer * > & trustGraph
Handle to Trust graph of network.