Topology Manager interface. More...
Go to the source code of this file.
Functions | |
struct nodeID ** | topGetNeighbourhood (int *n) |
Get the peer's neighbourhood. | |
const void * | topGetMetadata (int *metadata_size) |
Get the peer's metadata. | |
int | topGrowNeighbourhood (int n) |
Increase the neighbourhood size. | |
int | topShrinkNeighbourhood (int n) |
Decrease the neighbourhood size. | |
int | topRemoveNeighbour (struct nodeID *neighbour) |
Remove a peer from the neighbourhood. | |
int | topChangeMetadata (struct nodeID *peer, void *metadata, int metadata_size) |
Change the metadata. | |
int | topInit (struct nodeID *myID, void *metadata, int metadata_size, const char *config) |
Initialise the Topology Manager. | |
int | topAddNeighbour (struct nodeID *neighbour, void *metadata, int metadata_size) |
Insert a peer in the neighbourhood. | |
int | topParseData (const uint8_t *buff, int len) |
Pass a received packet to the Topology Manager. |
Topology Manager interface.
This is the Topology Manager interface. See topology_test.c for an usage example
int topAddNeighbour | ( | struct nodeID * | neighbour, | |
void * | metadata, | |||
int | metadata_size | |||
) |
Insert a peer in the neighbourhood.
This function can be used to add a specified neighbour to the neighbourhood. It is useful in the bootstrap phase.
neighbour | the id of the peer to be added to the neighbourhood. | |
metadata | pointer to the metadata associated to the new peer (will be gossiped). | |
metadata_size | size of the metadata associated to the new peer (must be the same as for the other peers). |
int topChangeMetadata | ( | struct nodeID * | peer, | |
void * | metadata, | |||
int | metadata_size | |||
) |
Change the metadata.
This function can be used to modify/update the metadata for a peer. Because of security concerns, only the metadata for the local peer can be modified.
peer | the id of the peer for which the metadata should be updated (only the local peer is acceptable). | |
metadata | pointer to the new metadata associated to the peer (will be gossiped). | |
metadata_size | size of the metadata associated to the peer (must be the same as for the other peers). |
const void* topGetMetadata | ( | int * | metadata_size | ) |
Get the peer's metadata.
Each peer in the neighbourhood can have some opaque metadata attached to it, and such metadata is gossiped together with the nodeIDs. This function returns the metadata currently associated to the neighbours of a peer, and the size of each object composing the metadata (metadata have the same structure for all the peers, so such size is constant). The neighbourhood size can be known by calling topGetNeighbourhood().
metadata_size | pointer to an integer where the size of the metadata associated to each peer is returned. Is set to -1 in case of error, or 0 if the neighbourhood is empty. |
struct nodeID** topGetNeighbourhood | ( | int * | n | ) | [read] |
Get the peer's neighbourhood.
This function returns the current neighbourhood (i.e., the set of known peers) of a peer, and its size. Note that the current neighbourhood size can be different from the requested one, because of how the overlay management protocols work.
n | pointer to an integer where the neighbourhood size is returned. Is set to -1 in case of error, or 0 if the neighbourhood is empty. |
int topGrowNeighbourhood | ( | int | n | ) |
Increase the neighbourhood size.
This function can be used to increase the number of neighbours (that is, the degree of the overlay graph) by a specified amount.
n | number of peers by which the neighbourhood size must be incremented. |
int topInit | ( | struct nodeID * | myID, | |
void * | metadata, | |||
int | metadata_size, | |||
const char * | config | |||
) |
Initialise the Topology Manager.
myID | the ID of this peer. | |
metadata | pointer to the metadata associated to this peer (will be gossiped). | |
metadata_size | size of the metadata associated to this peer. |
int topParseData | ( | const uint8_t * | buff, | |
int | len | |||
) |
Pass a received packet to the Topology Manager.
This function passes to the Topology Manager a packet that has been received from the network. The Topology Manager will parse such packet and run the protocol, adding or removing peers to the neighbourhood, and sending overlay management messages to other peers.
buff | a memory buffer containing the received message. | |
len | the size of such a memory buffer. |
int topRemoveNeighbour | ( | struct nodeID * | neighbour | ) |
Remove a peer from the neighbourhood.
This function can be used to remove a specified neighbour from the neighbourhood. Note that the requested neighbourhood size is not modified, so the peer will be soon replaced by a different one.
neighbour | the id of the peer to be removed from the neighbourhood. |
int topShrinkNeighbourhood | ( | int | n | ) |
Decrease the neighbourhood size.
This function can be used to reduce the number of neighbours (that is, the degree of the overlay graph) by a specified amount.
n | number of peers by which the neighbourhood size must be decreased. |