rippled
Public Types | Public Member Functions | Private Types | Private Attributes | Friends | List of all members
ripple::test::csf::PeerGroup Class Reference

A group of simulation Peers. More...

Collaboration diagram for ripple::test::csf::PeerGroup:
Collaboration graph
[legend]

Public Types

using iterator = peers_type::iterator
 
using const_iterator = peers_type::const_iterator
 
using reference = peers_type::reference
 
using const_reference = peers_type::const_reference
 

Public Member Functions

 PeerGroup ()=default
 
 PeerGroup (Peer *peer)
 
 PeerGroup (std::vector< Peer * > &&peers)
 
 PeerGroup (std::vector< Peer * > const &peers)
 
 PeerGroup (std::set< Peer * > const &peers)
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_reference operator[] (std::size_t i) const
 
bool contains (Peer const *p)
 
bool contains (PeerID id)
 
std::size_t size () const
 
void trust (PeerGroup const &o)
 Establish trust. More...
 
void untrust (PeerGroup const &o)
 Revoke trust. More...
 
void connect (PeerGroup const &o, SimDuration delay)
 Establish network connection. More...
 
void disconnect (PeerGroup const &o)
 Destroy network connection. More...
 
void trustAndConnect (PeerGroup const &o, SimDuration delay)
 Establish trust and network connection. More...
 
void connectFromTrust (SimDuration delay)
 Establish network connections based on trust relations. More...
 

Private Types

using peers_type = std::vector< Peer * >
 

Private Attributes

peers_type peers_
 

Friends

PeerGroup operator+ (PeerGroup const &a, PeerGroup const &b)
 
PeerGroup operator- (PeerGroup const &a, PeerGroup const &b)
 
std::ostreamoperator<< (std::ostream &o, PeerGroup const &t)
 

Detailed Description

A group of simulation Peers.

A PeerGroup is a convenient handle for logically grouping peers together, and then creating trust or network relations for the group at large. Peer groups may also be combined to build out more complex structures.

The PeerGroup provides random access style iterators and operator[]

Definition at line 39 of file PeerGroup.h.

Member Typedef Documentation

◆ peers_type

Definition at line 41 of file PeerGroup.h.

◆ iterator

using ripple::test::csf::PeerGroup::iterator = peers_type::iterator

Definition at line 45 of file PeerGroup.h.

◆ const_iterator

using ripple::test::csf::PeerGroup::const_iterator = peers_type::const_iterator

Definition at line 46 of file PeerGroup.h.

◆ reference

using ripple::test::csf::PeerGroup::reference = peers_type::reference

Definition at line 47 of file PeerGroup.h.

◆ const_reference

using ripple::test::csf::PeerGroup::const_reference = peers_type::const_reference

Definition at line 48 of file PeerGroup.h.

Constructor & Destructor Documentation

◆ PeerGroup() [1/5]

ripple::test::csf::PeerGroup::PeerGroup ( )
default

◆ PeerGroup() [2/5]

ripple::test::csf::PeerGroup::PeerGroup ( Peer peer)

Definition at line 51 of file PeerGroup.h.

◆ PeerGroup() [3/5]

ripple::test::csf::PeerGroup::PeerGroup ( std::vector< Peer * > &&  peers)

Definition at line 54 of file PeerGroup.h.

◆ PeerGroup() [4/5]

ripple::test::csf::PeerGroup::PeerGroup ( std::vector< Peer * > const &  peers)

Definition at line 58 of file PeerGroup.h.

◆ PeerGroup() [5/5]

ripple::test::csf::PeerGroup::PeerGroup ( std::set< Peer * > const &  peers)

Definition at line 63 of file PeerGroup.h.

Member Function Documentation

◆ begin() [1/2]

iterator ripple::test::csf::PeerGroup::begin ( )

Definition at line 68 of file PeerGroup.h.

◆ end() [1/2]

iterator ripple::test::csf::PeerGroup::end ( )

Definition at line 74 of file PeerGroup.h.

◆ begin() [2/2]

const_iterator ripple::test::csf::PeerGroup::begin ( ) const

Definition at line 80 of file PeerGroup.h.

◆ end() [2/2]

const_iterator ripple::test::csf::PeerGroup::end ( ) const

Definition at line 86 of file PeerGroup.h.

◆ operator[]()

const_reference ripple::test::csf::PeerGroup::operator[] ( std::size_t  i) const

Definition at line 92 of file PeerGroup.h.

◆ contains() [1/2]

bool ripple::test::csf::PeerGroup::contains ( Peer const *  p)

Definition at line 98 of file PeerGroup.h.

◆ contains() [2/2]

bool ripple::test::csf::PeerGroup::contains ( PeerID  id)

Definition at line 104 of file PeerGroup.h.

◆ size()

std::size_t ripple::test::csf::PeerGroup::size ( ) const

Definition at line 112 of file PeerGroup.h.

◆ trust()

void ripple::test::csf::PeerGroup::trust ( PeerGroup const &  o)

Establish trust.

Establish trust from all peers in this group to all peers in o

Parameters
oThe group of peers to trust

Definition at line 124 of file PeerGroup.h.

◆ untrust()

void ripple::test::csf::PeerGroup::untrust ( PeerGroup const &  o)

Revoke trust.

Revoke trust from all peers in this group to all peers in o

Parameters
oThe group of peers to untrust

Definition at line 142 of file PeerGroup.h.

◆ connect()

void ripple::test::csf::PeerGroup::connect ( PeerGroup const &  o,
SimDuration  delay 
)

Establish network connection.

Establish outbound connections from all peers in this group to all peers in o. If a connection already exists, no new connection is established.

Parameters
oThe group of peers to connect to (will get inbound connections)
delayThe fixed messaging delay for all established connections

Definition at line 164 of file PeerGroup.h.

◆ disconnect()

void ripple::test::csf::PeerGroup::disconnect ( PeerGroup const &  o)

Destroy network connection.

Destroy connections from all peers in this group to all peers in o

Parameters
oThe group of peers to disconnect from

Definition at line 184 of file PeerGroup.h.

◆ trustAndConnect()

void ripple::test::csf::PeerGroup::trustAndConnect ( PeerGroup const &  o,
SimDuration  delay 
)

Establish trust and network connection.

Establish trust and create a network connection with fixed delay from all peers in this group to all peers in o

Parameters
oThe group of peers to trust and connect to
delayThe fixed messaging delay for all established connections

Definition at line 204 of file PeerGroup.h.

◆ connectFromTrust()

void ripple::test::csf::PeerGroup::connectFromTrust ( SimDuration  delay)

Establish network connections based on trust relations.

For each peers in this group, create outbound network connection to the set of peers it trusts. If a coonnection already exists, it is not recreated.

Parameters
delayThe fixed messaging delay for all established connections

Definition at line 220 of file PeerGroup.h.

Friends And Related Function Documentation

◆ operator+

PeerGroup operator+ ( PeerGroup const &  a,
PeerGroup const &  b 
)
friend

Definition at line 233 of file PeerGroup.h.

◆ operator-

PeerGroup operator- ( PeerGroup const &  a,
PeerGroup const &  b 
)
friend

Definition at line 247 of file PeerGroup.h.

◆ operator<<

std::ostream& operator<< ( std::ostream o,
PeerGroup const &  t 
)
friend

Definition at line 262 of file PeerGroup.h.

Member Data Documentation

◆ peers_

peers_type ripple::test::csf::PeerGroup::peers_
private

Definition at line 42 of file PeerGroup.h.