wrapper around the "local view" More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet-service-rps_view.h"
#include <inttypes.h>
Go to the source code of this file.
Data Structures | |
struct | View |
Functions | |
struct View * | View_create (uint32_t len) |
Create an empty view. More... | |
void | View_change_len (struct View *view, uint32_t len) |
Change length of view. More... | |
const struct GNUNET_PeerIdentity * | View_get_as_array (const struct View *view) |
Get the view as an array. More... | |
unsigned int | View_size (const struct View *view) |
Get the size of the view. More... | |
int | View_put (struct View *view, const struct GNUNET_PeerIdentity *peer) |
Insert peer into the view. More... | |
int | View_contains_peer (const struct View *view, const struct GNUNET_PeerIdentity *peer) |
Check whether view contains a peer. More... | |
int | View_remove_peer (struct View *view, const struct GNUNET_PeerIdentity *peer) |
Remove peer from view. More... | |
const struct GNUNET_PeerIdentity * | View_get_peer_by_index (const struct View *view, uint32_t index) |
Get a peer by index. More... | |
void | View_clear (struct View *view) |
Clear the view. More... | |
void | View_destroy (struct View *view) |
Destroy view. More... | |
wrapper around the "local view"
Definition in file gnunet-service-rps_view.c.
struct View * View_create | ( | uint32_t | len | ) |
Create an empty view.
len | the maximum length for the view |
Definition at line 57 of file gnunet-service-rps_view.c.
References View::array, GNUNET_CONTAINER_multipeermap_create(), GNUNET_new, GNUNET_new_array, GNUNET_NO, View::length, and View::mpm.
Referenced by new_sub().
void View_change_len | ( | struct View * | view, |
uint32_t | len | ||
) |
Change length of view.
If size is decreased, peers with higher indices are removed.
view | The view that is changed |
len | the (maximum) length for the view |
Definition at line 80 of file gnunet-service-rps_view.c.
References View::array, GNUNET_array_grow, GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CONTAINER_multipeermap_create(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_get(), GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_free, GNUNET_new, GNUNET_NO, View::length, and View::mpm.
Referenced by adapt_sizes().
const struct GNUNET_PeerIdentity * View_get_as_array | ( | const struct View * | view | ) |
Get the view as an array.
view | The view of which the array representation is of interest |
Definition at line 122 of file gnunet-service-rps_view.c.
References View::array.
Referenced by clients_notify_view_update(), do_round(), handle_peer_pull_request(), and send_view().
unsigned int View_size | ( | const struct View * | view | ) |
Get the size of the view.
view | The view of which the size should be returned |
Definition at line 135 of file gnunet-service-rps_view.c.
References GNUNET_CONTAINER_multipeermap_size(), and View::mpm.
Referenced by clients_notify_view_update(), do_round(), handle_peer_pull_request(), insert_in_view(), send_view(), View_clear(), View_put(), and View_remove_peer().
int View_put | ( | struct View * | view, |
const struct GNUNET_PeerIdentity * | peer | ||
) |
Insert peer into the view.
view | The view to put the peer into |
peer | the peer to insert |
Definition at line 151 of file gnunet-service-rps_view.c.
References View::array, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CONTAINER_multipeermap_put(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_YES, View::length, View::mpm, View_contains_peer(), and View_size().
Referenced by insert_in_view().
int View_contains_peer | ( | const struct View * | view, |
const struct GNUNET_PeerIdentity * | peer | ||
) |
Check whether view contains a peer.
view | The which is checked for a peer |
peer | the peer to check for |
Definition at line 183 of file gnunet-service-rps_view.c.
References GNUNET_CONTAINER_multipeermap_contains(), and View::mpm.
Referenced by check_sending_channel_needed(), clean_peer(), View_put(), and View_remove_peer().
int View_remove_peer | ( | struct View * | view, |
const struct GNUNET_PeerIdentity * | peer | ||
) |
Remove peer from view.
view | The view of which to remove the peer |
peer | the peer to remove |
Definition at line 200 of file gnunet-service-rps_view.c.
References View::array, GNUNET_assert, GNUNET_CONTAINER_multipeermap_get(), GNUNET_CONTAINER_multipeermap_remove_all(), GNUNET_free, GNUNET_NO, GNUNET_OK, GNUNET_YES, View::mpm, View_contains_peer(), and View_size().
Referenced by remove_peer().
const struct GNUNET_PeerIdentity * View_get_peer_by_index | ( | const struct View * | view, |
uint32_t | index | ||
) |
Get a peer by index.
view | the view of which to get the peer |
index | the index of the peer to get |
Definition at line 240 of file gnunet-service-rps_view.c.
References View::array, GNUNET_CONTAINER_multipeermap_size(), and View::mpm.
void View_clear | ( | struct View * | view | ) |
Clear the view.
view | The view to clear |
Definition at line 260 of file gnunet-service-rps_view.c.
References View::array, GNUNET_assert, GNUNET_CONTAINER_multipeermap_contains(), GNUNET_CONTAINER_multipeermap_get(), GNUNET_CONTAINER_multipeermap_remove_all(), GNUNET_free, GNUNET_YES, View::mpm, and View_size().
Referenced by do_round(), and View_destroy().
void View_destroy | ( | struct View * | view | ) |
Destroy view.
view | the view to destroy |
Definition at line 284 of file gnunet-service-rps_view.c.
References View::array, GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_free, View::mpm, and View_clear().
Referenced by destroy_sub().