3#include <test/csf/Peer.h>
4#include <test/csf/random.h>
152 p->connect(*target, delay);
170 p->disconnect(*target);
204 for (
Peer* to : peer->trustGraph.trustedPeers(peer))
206 peer->connect(*to, delay);
238 for (
Peer const* p : t)
269template <
class RandomNumberDistribution,
class Generator>
275 RandomNumberDistribution sizeDist,
278 assert(peers.
size() == ranks.
size());
296template <
class RandomNumberDistribution,
class Generator>
302 RandomNumberDistribution sizeDist,
308 for (
auto& peer : peers)
310 for (
auto& target : groups[u(g)])
311 peer->trust(*target);
319template <
class RandomNumberDistribution,
class Generator>
325 RandomNumberDistribution sizeDist,
332 for (
auto& peer : peers)
334 for (
auto& target : groups[u(g)])
335 peer->connect(*target, delay);
T back_inserter(T... args)
A group of simulation Peers.
peers_type::reference reference
peers_type::const_reference const_reference
friend PeerGroup operator+(PeerGroup const &a, PeerGroup const &b)
const_reference operator[](std::size_t i) const
void connectFromTrust(SimDuration delay)
Establish network connections based on trust relations.
void trust(PeerGroup const &o)
Establish trust.
void disconnect(PeerGroup const &o)
Destroy network connection.
void connect(PeerGroup const &o, SimDuration delay)
Establish network connection.
friend std::ostream & operator<<(std::ostream &o, PeerGroup const &t)
void trustAndConnect(PeerGroup const &o, SimDuration delay)
Establish trust and network connection.
peers_type::iterator iterator
PeerGroup(std::vector< Peer * > &&peers)
const_iterator end() const
bool contains(Peer const *p)
void untrust(PeerGroup const &o)
Revoke trust.
friend PeerGroup operator-(PeerGroup const &a, PeerGroup const &b)
const_iterator begin() const
PeerGroup(std::set< Peer * > const &peers)
peers_type::const_iterator const_iterator
PeerGroup(std::vector< Peer * > const &peers)
typename SimClock::duration SimDuration
std::vector< PeerGroup > randomRankedGroups(PeerGroup &peers, std::vector< double > const &ranks, int numGroups, RandomNumberDistribution sizeDist, Generator &g)
Randomly generate peer groups according to ranks.
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.
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.
void randomRankedTrust(PeerGroup &peers, std::vector< double > const &ranks, int numGroups, RandomNumberDistribution sizeDist, Generator &g)
Generate random trust groups based on peer rankings.
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.