Structure containing a set of peers. More...
Go to the source code of this file.
Typedefs | |
| typedef struct peerset | PeerSet |
Functions | |
| struct peerset * | peerset_init (const char *config) |
| Allocate a peer set. | |
| int | peerset_add_peer (struct peerset *h, struct nodeID *id) |
| Add a peer to the set. | |
| void | peerset_add_peers (struct peerset *h, struct nodeID **ids, int n) |
| Add peers to the set. | |
| int | peerset_remove_peer (struct peerset *h, const struct nodeID *id) |
| Remove a peer from the set. | |
| struct peer * | peerset_get_peer (const struct peerset *h, const struct nodeID *id) |
| Get a peer if it is in the set. | |
| int | peerset_size (const struct peerset *h) |
| Get the set size. | |
| struct peer * | peerset_get_peers (const struct peerset *h) |
| Get a peer from a set. | |
| int | peerset_check (const struct peerset *h, const struct nodeID *id) |
| Check if a peer is in a set. | |
| void | peerset_clear (struct peerset *h, int size) |
| Clear a set. | |
Structure containing a set of peers.
The Peer Set is an abstract data structure that can contain a set of peer structures. It handles peers by their nodeIDs. Peer structures are created and accessed based on their nodeID (i.e. unique address).
| typedef struct peerset PeerSet |
Opaque data type representing a Peer Set
| int peerset_add_peer | ( | struct peerset * | h, | |
| struct nodeID * | id | |||
| ) |
Add a peer to the set.
Insert a peer to the set, creating the peer structure. If the peer is already in the set, nothing happens.
| h | a pointer to the set where the peer has to be added | |
| id | the ID of the peer to be inserted in the set |
| void peerset_add_peers | ( | struct peerset * | h, | |
| struct nodeID ** | ids, | |||
| int | n | |||
| ) |
Add peers to the set.
Comodity function to add several peers at the same time to the set. See peerset_add_peer
| h | a pointer to the set where the peer has to be added | |
| ids | the IDs of the peers to be inserted in the set | |
| n | length of the its array |
| int peerset_check | ( | const struct peerset * | h, | |
| const struct nodeID * | id | |||
| ) |
Check if a peer is in a set.
| h | a pointer to the set | |
| id | the nodeID we are searching for |
| void peerset_clear | ( | struct peerset * | h, | |
| int | size | |||
| ) |
Clear a set.
Remove all the peers from a set.
| h | a pointer to the set | |
| size | the expected number of peers that will be stored in the set; 0 if such a number is not known. |
| struct peer* peerset_get_peer | ( | const struct peerset * | h, | |
| const struct nodeID * | id | |||
| ) | [read] |
Get a peer if it is in the set.
| h | a pointer to the set | |
| id | the nodeID we are searching for |
| struct peer* peerset_get_peers | ( | const struct peerset * | h | ) | [read] |
Get a peer from a set.
Return the peers of the set. The peer's priority is assumed to depend on i.
| h | a pointer to the set |
| struct peerset* peerset_init | ( | const char * | config | ) | [read] |
Allocate a peer set.
Create an empty peer set, and return a pointer to it.
| config | a string containing tags which describe the peerset. For example, the "size" tag indicates the expected number of peers that will be stored in the set; 0 or not present if such a number is not known. |
| int peerset_remove_peer | ( | struct peerset * | h, | |
| const struct nodeID * | id | |||
| ) |
Remove a peer from the set.
Remove a peer from the set, distroying all associated data. If peer exists, pointers of peerset_get_peers move backwards.
| h | a pointer to the set where the peer has to be added | |
| id | the ID of the peer to be removed from the set |
| int peerset_size | ( | const struct peerset * | h | ) |
Get the set size.
Return the number of peers present in a set.
| h | a pointer to the set |
1.6.3