utilities for managing (information about) peers More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet-service-rps_custommap.h"
#include <inttypes.h>
Go to the source code of this file.
Data Structures | |
struct | CustomPeerMap |
Peer map to store peers with specialised use-cases (push_list, pull_list, view, ...) More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "rps-peers", __VA_ARGS__) |
Functions | |
struct CustomPeerMap * | CustomPeerMap_create (unsigned int len) |
Create an empty peermap. More... | |
unsigned int | CustomPeerMap_size (const struct CustomPeerMap *c_peer_map) |
Get the size of the custom peer map. More... | |
int | CustomPeerMap_put (const struct CustomPeerMap *c_peer_map, const struct GNUNET_PeerIdentity *peer) |
Insert peer into the custom peer map. More... | |
int | CustomPeerMap_contains_peer (const struct CustomPeerMap *c_peer_map, const struct GNUNET_PeerIdentity *peer) |
Check whether custom peer map contains a peer. More... | |
static uint32_t * | CustomPeerMap_get_index_pointer (const struct CustomPeerMap *c_peer_map, const struct GNUNET_PeerIdentity *peer) |
Get index of peer in custom peer map. More... | |
int | CustomPeerMap_remove_peer (const struct CustomPeerMap *c_peer_map, const struct GNUNET_PeerIdentity *peer) |
Remove peer from custom peer map. More... | |
struct GNUNET_PeerIdentity * | CustomPeerMap_get_peer_by_index (const struct CustomPeerMap *c_peer_map, uint32_t index) |
Get a peer by index. More... | |
int | CustomPeerMap_remove_peer_by_index (const struct CustomPeerMap *c_peer_map, uint32_t index) |
Remove peer from custom peer map by index. More... | |
void | CustomPeerMap_clear (const struct CustomPeerMap *c_peer_map) |
Clear the custom peer map. More... | |
void | CustomPeerMap_destroy (struct CustomPeerMap *c_peer_map) |
Destroy peermap. More... | |
utilities for managing (information about) peers
Definition in file gnunet-service-rps_custommap.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "rps-peers", __VA_ARGS__) |
Definition at line 31 of file gnunet-service-rps_custommap.c.
struct CustomPeerMap * CustomPeerMap_create | ( | unsigned int | len | ) |
Create an empty peermap.
len | the initial length for the internal maps |
Definition at line 79 of file gnunet-service-rps_custommap.c.
References GNUNET_CONTAINER_multihashmap32_create(), GNUNET_CONTAINER_multipeermap_create(), GNUNET_new, GNUNET_NO, CustomPeerMap::hash_map, and CustomPeerMap::peer_map.
Referenced by new_sub().
unsigned int CustomPeerMap_size | ( | const struct CustomPeerMap * | c_peer_map | ) |
Get the size of the custom peer map.
c_peer_map | the custom peer map to look in |
Definition at line 99 of file gnunet-service-rps_custommap.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap32_size(), GNUNET_CONTAINER_multipeermap_size(), CustomPeerMap::hash_map, and CustomPeerMap::peer_map.
Referenced by CustomPeerMap_clear(), CustomPeerMap_put(), CustomPeerMap_remove_peer(), CustomPeerMap_remove_peer_by_index(), and do_round().
int CustomPeerMap_put | ( | const struct CustomPeerMap * | c_peer_map, |
const struct GNUNET_PeerIdentity * | peer | ||
) |
Insert peer into the custom peer map.
c_peer_map | the custom peer map to insert peer |
peer | the peer to insert |
Definition at line 117 of file gnunet-service-rps_custommap.c.
References CustomPeerMap_size(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_put(), GNUNET_CONTAINER_multihashmap32_size(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CONTAINER_multipeermap_contains(), GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_new, GNUNET_NO, GNUNET_OK, CustomPeerMap::hash_map, p, and CustomPeerMap::peer_map.
Referenced by handle_peer_pull_reply(), handle_peer_push(), and insert_in_pull_map().
int CustomPeerMap_contains_peer | ( | const struct CustomPeerMap * | c_peer_map, |
const struct GNUNET_PeerIdentity * | peer | ||
) |
Check whether custom peer map contains a peer.
c_peer_map | the custom peer map to look in |
peer | the peer to check for |
Definition at line 165 of file gnunet-service-rps_custommap.c.
References GNUNET_CONTAINER_multipeermap_contains(), and CustomPeerMap::peer_map.
Referenced by check_sending_channel_needed(), clean_peer(), CustomPeerMap_get_index_pointer(), and CustomPeerMap_remove_peer().
|
static |
Get index of peer in custom peer map.
c_peer_map | the custom peer map to look in |
peer | the peer to get the index from |
Definition at line 181 of file gnunet-service-rps_custommap.c.
References CustomPeerMap_contains_peer(), GNUNET_assert, GNUNET_CONTAINER_multipeermap_get(), GNUNET_YES, and CustomPeerMap::peer_map.
Referenced by CustomPeerMap_remove_peer(), and CustomPeerMap_remove_peer_by_index().
int CustomPeerMap_remove_peer | ( | const struct CustomPeerMap * | c_peer_map, |
const struct GNUNET_PeerIdentity * | peer | ||
) |
Remove peer from custom peer map.
c_peer_map | the custom peer map to remove the peer from |
peer | the peer to remove |
Definition at line 202 of file gnunet-service-rps_custommap.c.
References CustomPeerMap_contains_peer(), CustomPeerMap_get_index_pointer(), CustomPeerMap_size(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_get(), GNUNET_CONTAINER_multihashmap32_put(), GNUNET_CONTAINER_multihashmap32_remove_all(), GNUNET_CONTAINER_multihashmap32_size(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_get(), GNUNET_CONTAINER_multipeermap_remove_all(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_free, GNUNET_NO, GNUNET_OK, CustomPeerMap::hash_map, p, CustomPeerMap::peer_map, and ret.
Referenced by CustomPeerMap_remove_peer_by_index(), and remove_peer().
struct GNUNET_PeerIdentity * CustomPeerMap_get_peer_by_index | ( | const struct CustomPeerMap * | c_peer_map, |
uint32_t | index | ||
) |
Get a peer by index.
c_peer_map | the custom peer map to look in |
index | the index of the peer to get |
Definition at line 265 of file gnunet-service-rps_custommap.c.
References GNUNET_CONTAINER_multihashmap32_contains(), GNUNET_CONTAINER_multihashmap32_get(), GNUNET_YES, and CustomPeerMap::hash_map.
Referenced by CustomPeerMap_remove_peer_by_index(), and do_round().
int CustomPeerMap_remove_peer_by_index | ( | const struct CustomPeerMap * | c_peer_map, |
uint32_t | index | ||
) |
Remove peer from custom peer map by index.
c_peer_map | the custom peer map to remove the peer from |
index | the index of the peer to remove |
Definition at line 287 of file gnunet-service-rps_custommap.c.
References CustomPeerMap_get_index_pointer(), CustomPeerMap_get_peer_by_index(), CustomPeerMap_remove_peer(), CustomPeerMap_size(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_contains(), GNUNET_CONTAINER_multihashmap32_size(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_NO, GNUNET_OK, CustomPeerMap::hash_map, and CustomPeerMap::peer_map.
Referenced by CustomPeerMap_clear().
void CustomPeerMap_clear | ( | const struct CustomPeerMap * | c_peer_map | ) |
Clear the custom peer map.
c_peer_map | the custom peer map to look in |
Definition at line 323 of file gnunet-service-rps_custommap.c.
References CustomPeerMap_remove_peer_by_index(), CustomPeerMap_size(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_contains(), GNUNET_OK, GNUNET_YES, and CustomPeerMap::hash_map.
Referenced by CustomPeerMap_destroy(), and do_round().
void CustomPeerMap_destroy | ( | struct CustomPeerMap * | c_peer_map | ) |
Destroy peermap.
c_peer_map | the map to destroy |
Definition at line 347 of file gnunet-service-rps_custommap.c.
References CustomPeerMap_clear(), GNUNET_CONTAINER_multihashmap32_destroy(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_free, CustomPeerMap::hash_map, and CustomPeerMap::peer_map.
Referenced by destroy_sub().