rps service implementation More...
#include "platform.h"
#include "gnunet_applications.h"
#include "gnunet_util_lib.h"
#include "gnunet_cadet_service.h"
#include "gnunet_core_service.h"
#include "gnunet_peerstore_service.h"
#include "gnunet_nse_service.h"
#include "gnunet_statistics_service.h"
#include "rps.h"
#include "rps-test_util.h"
#include "gnunet-service-rps_sampler.h"
#include "gnunet-service-rps_custommap.h"
#include "gnunet-service-rps_view.h"
#include "gnunet_constants.h"
#include <math.h>
#include <inttypes.h>
#include <string.h>
Go to the source code of this file.
Data Structures | |
struct | PeerPendingOp |
Pending operation on peer consisting of callback and closure. More... | |
struct | PendingMessage |
List containing all messages that are yet to be send. More... | |
struct | PeerContext |
Struct used to keep track of other peer's status. More... | |
struct | PeersIteratorCls |
Closure to valid_peer_iterator. More... | |
struct | ChannelCtx |
Context for a channel. More... | |
struct | Sub |
One Sub. More... | |
struct | GetRandPeerIteratorCls |
The closure to get_rand_peer_iterator. More... | |
struct | ReplyCls |
Closure used to pass the client and the id to the callback that replies to a client's request. More... | |
struct | ClientContext |
Struct used to store the context of a connected client. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) |
#define | SET_PEER_FLAG(peer_ctx, mask) ((peer_ctx->peer_flags) |= (mask)) |
Set a peer flag of given peer context. More... | |
#define | check_peer_flag_set(peer_ctx, mask) ((peer_ctx->peer_flags) & (mask) ? GNUNET_YES : GNUNET_NO) |
Get peer flag of given peer context. More... | |
#define | UNSET_PEER_FLAG(peer_ctx, mask) ((peer_ctx->peer_flags) &= ~(mask)) |
Unset flag of given peer context. More... | |
#define | check_channel_flag_set(channel_flags, mask) ((*channel_flags) & (mask) ? GNUNET_YES : GNUNET_NO) |
Get channel flag of given channel context. More... | |
#define | unset_channel_flag(channel_flags, mask) ((*channel_flags) &= ~(mask)) |
Unset flag of given channel context. More... | |
#define | HISTOGRAM_FILE_SLOTS 32 |
This number determines the number of slots for files that represent histograms. More... | |
#define | SIZE_DUMP_FILE (HISTOGRAM_FILE_SLOTS * 5) + 1 |
The size (in bytes) a file needs to store the histogram. More... | |
Functions | |
static void | do_round (void *cls) |
Send out PUSHes and PULLs, possibly update #view, samplers. More... | |
static struct PeerContext * | get_peer_ctx (const struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct GNUNET_PeerIdentity *peer) |
Get the PeerContext associated with a peer. More... | |
static int | check_peer_known (const struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct GNUNET_PeerIdentity *peer) |
Check whether we have information about the given peer. More... | |
static struct PeerContext * | create_peer_ctx (struct Sub *sub, const struct GNUNET_PeerIdentity *peer) |
Create a new PeerContext and insert it into the peer map. More... | |
static struct PeerContext * | create_or_get_peer_ctx (struct Sub *sub, const struct GNUNET_PeerIdentity *peer) |
Create or get a PeerContext. More... | |
static int | check_connected (struct PeerContext *peer_ctx) |
Check whether we have a connection to this peer. More... | |
static int | get_rand_peer_iterator (void *cls, const struct GNUNET_PeerIdentity *peer, void *value) |
Iterator function for get_random_peer_from_peermap. More... | |
static const struct GNUNET_PeerIdentity * | get_random_peer_from_peermap (struct GNUNET_CONTAINER_MultiPeerMap *valid_peers) |
Get a random peer from peer_map. More... | |
static int | add_valid_peer (const struct GNUNET_PeerIdentity *peer, struct GNUNET_CONTAINER_MultiPeerMap *valid_peers) |
Add a given peer to valid peers. More... | |
static void | remove_pending_message (struct PendingMessage *pending_msg, int cancel) |
Remove a pending message from the respective DLL. More... | |
static void | set_peer_online (struct PeerContext *peer_ctx) |
Set the peer flag to living and call the pending operations on this peer. More... | |
static void | cleanup_destroyed_channel (void *cls, const struct GNUNET_CADET_Channel *channel) |
This is called when a channel is destroyed. More... | |
static void | handle_peer_check (void *cls, const struct GNUNET_MessageHeader *msg) |
Handle a CHECK_LIVE message from another peer. More... | |
static void | handle_peer_push (void *cls, const struct GNUNET_MessageHeader *msg) |
Handle a PUSH message from another peer. More... | |
static void | handle_peer_pull_request (void *cls, const struct GNUNET_MessageHeader *msg) |
Handle PULL REQUEST request message from another peer. More... | |
static int | check_peer_pull_reply (void *cls, const struct GNUNET_RPS_P2P_PullReplyMessage *msg) |
Check whether we sent a corresponding request and whether this reply is the first one. More... | |
static void | handle_peer_pull_reply (void *cls, const struct GNUNET_RPS_P2P_PullReplyMessage *msg) |
Handle PULL REPLY message from another peer. More... | |
static struct ChannelCtx * | add_channel_ctx (struct PeerContext *peer_ctx) |
Allocate memory for a new channel context and insert it into DLL. More... | |
static void | remove_channel_ctx (struct ChannelCtx *channel_ctx) |
Free memory and NULL pointers. More... | |
struct GNUNET_CADET_Channel * | get_channel (struct PeerContext *peer_ctx) |
Get the channel of a peer. More... | |
static struct GNUNET_MQ_Handle * | get_mq (struct PeerContext *peer_ctx) |
Get the message queue (GNUNET_MQ_Handle) of a specific peer. More... | |
static struct PendingMessage * | insert_pending_message (struct PeerContext *peer_ctx, struct GNUNET_MQ_Envelope *ev, const char *type) |
Add an envelope to a message passed to mq to list of pending messages. More... | |
static void | mq_online_check_successful (void *cls) |
This is called in response to the first message we sent as a online check. More... | |
static void | check_peer_online (struct PeerContext *peer_ctx) |
Issue a check whether peer is online. More... | |
static int | check_operation_scheduled (const struct PeerContext *peer_ctx, const PeerOp peer_op) |
Check whether function of type PeerOp was already scheduled. More... | |
static void | destroy_channel (struct ChannelCtx *channel_ctx) |
Callback for scheduler to destroy a channel. More... | |
static void | destroy_channel_cb (void *cls) |
Destroy a cadet channel. More... | |
static void | schedule_channel_destruction (struct ChannelCtx *channel_ctx) |
Schedule the destruction of a channel for immediately afterwards. More... | |
static int | destroy_peer (struct PeerContext *peer_ctx) |
Remove peer. More... | |
static int | peermap_clear_iterator (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Iterator over hash map entries. More... | |
static void | mq_notify_sent_cb (void *cls) |
This is called once a message is sent. More... | |
static int | store_peer_presistently_iterator (void *cls, const struct GNUNET_PeerIdentity *peer, void *value) |
Iterator function for store_valid_peers. More... | |
static void | store_valid_peers (const struct Sub *sub) |
Store the peers currently in #valid_peers to disk. More... | |
static const struct GNUNET_PeerIdentity * | s2i_full (const char *string_repr) |
Convert string representation of peer id to peer id. More... | |
static void | restore_valid_peers (const struct Sub *sub) |
Restore the peers on disk to #valid_peers. More... | |
static void | peers_terminate (struct Sub *sub) |
Delete storage of peers that was created with #initialise_peers () More... | |
static int | valid_peer_iterator (void *cls, const struct GNUNET_PeerIdentity *peer, void *value) |
Iterator over #valid_peers hash map entries. More... | |
static int | get_valid_peers (struct GNUNET_CONTAINER_MultiPeerMap *valid_peers, PeersIterator iterator, void *it_cls) |
Get all currently known, valid peer ids. More... | |
static int | insert_peer (struct Sub *sub, const struct GNUNET_PeerIdentity *peer) |
Add peer to known peers. More... | |
static int | check_peer_flag (const struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags) |
Check whether flags on a peer are set. More... | |
static int | issue_peer_online_check (struct Sub *sub, const struct GNUNET_PeerIdentity *peer) |
Try connecting to a peer to see whether it is online. More... | |
static int | check_removable (const struct PeerContext *peer_ctx) |
Check if peer is removable. More... | |
static int | check_peer_valid (const struct GNUNET_CONTAINER_MultiPeerMap *valid_peers, const struct GNUNET_PeerIdentity *peer) |
Check whether peer is actually a peer. More... | |
static void | indicate_sending_intention (struct PeerContext *peer_ctx) |
Indicate that we want to send to the other peer. More... | |
static int | check_peer_send_intention (const struct PeerContext *peer_ctx) |
Check whether other peer has the intention to send/opened channel towars us. More... | |
static void * | handle_inbound_channel (void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *initiator) |
Handle the channel a peer opens to us. More... | |
static int | check_sending_channel_exists (const struct PeerContext *peer_ctx) |
Check whether a sending channel towards the given peer exists. More... | |
static int | destroy_sending_channel (struct PeerContext *peer_ctx) |
Destroy the send channel of a peer e.g. More... | |
static void | send_message (struct PeerContext *peer_ctx, struct GNUNET_MQ_Envelope *ev, const char *type) |
Send a message to another peer. More... | |
static int | schedule_operation (struct PeerContext *peer_ctx, const PeerOp peer_op, void *cls) |
Schedule a operation on given peer. More... | |
static void | print_peer_list (struct GNUNET_PeerIdentity *list, unsigned int len) |
Print peerlist to log. More... | |
static void | rem_from_list (struct GNUNET_PeerIdentity **peer_list, unsigned int *list_size, const struct GNUNET_PeerIdentity *peer) |
Remove peer from list. More... | |
static void | insert_in_view_op (void *cls, const struct GNUNET_PeerIdentity *peer) |
Insert PeerID in #view. More... | |
static int | insert_in_view (struct Sub *sub, const struct GNUNET_PeerIdentity *peer) |
Insert PeerID in #view. More... | |
static void | send_view (const struct ClientContext *cli_ctx, const struct GNUNET_PeerIdentity *view_array, uint64_t view_size) |
Send view to client. More... | |
static void | send_stream_peers (const struct ClientContext *cli_ctx, uint64_t num_peers, const struct GNUNET_PeerIdentity *peers) |
Send peer from biased stream to client. More... | |
static void | clients_notify_view_update (const struct Sub *sub) |
sends updates to clients that are interested More... | |
static void | clients_notify_stream_peer (const struct Sub *sub, uint64_t num_peers, const struct GNUNET_PeerIdentity *peers) |
sends updates to clients that are interested More... | |
static void | hist_update (const struct GNUNET_PeerIdentity *ids, uint32_t num_peers, void *cls) |
Put random peer from sampler into the view as history update. More... | |
static void | resize_wrapper (struct RPS_Sampler *sampler, uint32_t new_size) |
Wrapper around RPS_sampler_resize() More... | |
static void | send_pull_reply (struct PeerContext *peer_ctx, const struct GNUNET_PeerIdentity *peer_ids, unsigned int num_peer_ids) |
Send a PULL REPLY to peer_id. More... | |
static void | insert_in_pull_map (void *cls, const struct GNUNET_PeerIdentity *peer) |
Insert PeerID in #pull_map. More... | |
static void | insert_in_sampler (void *cls, const struct GNUNET_PeerIdentity *peer) |
Update sampler with given PeerID. More... | |
static void | got_peer (struct Sub *sub, const struct GNUNET_PeerIdentity *peer) |
This is called on peers from external sources (cadet, peerinfo, ...) If the peer is not known, online check is issued and it is scheduled to be inserted in sampler and view. More... | |
static int | check_sending_channel_needed (const struct PeerContext *peer_ctx) |
Checks if there is a sending channel and if it is needed. More... | |
static void | remove_peer (struct Sub *sub, const struct GNUNET_PeerIdentity *peer) |
remove peer from our knowledge, the view, push and pull maps and samplers. More... | |
static void | clean_peer (struct Sub *sub, const struct GNUNET_PeerIdentity *peer) |
Remove data that is not needed anymore. More... | |
struct Sub * | new_sub (const struct GNUNET_HashCode *hash, uint32_t sampler_size, struct GNUNET_TIME_Relative round_interval) |
Create a new Sub. More... | |
static void | destroy_sub (struct Sub *sub) |
Destroy Sub. More... | |
void | core_init (void *cls, const struct GNUNET_PeerIdentity *my_identity) |
Callback on initialisation of Core. More... | |
void * | core_connects (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq) |
Callback for core. More... | |
void | core_disconnects (void *cls, const struct GNUNET_PeerIdentity *peer, void *peer_cls) |
Callback for core. More... | |
static void | destroy_cli_ctx (struct ClientContext *cli_ctx) |
Destroy the context for a (connected) client. More... | |
static void | adapt_sizes (struct Sub *sub, double logestimate, double std_dev) |
Update sizes in sampler and view on estimate update from nse service. More... | |
static void | nse_callback (void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimate, double std_dev) |
Function called by NSE. More... | |
static int | check_client_seed (void *cls, const struct GNUNET_RPS_CS_SeedMessage *msg) |
This function is called, when the client seeds peers. More... | |
static void | handle_client_seed (void *cls, const struct GNUNET_RPS_CS_SeedMessage *msg) |
Handle seed from the client. More... | |
static void | handle_client_view_request (void *cls, const struct GNUNET_RPS_CS_DEBUG_ViewRequest *msg) |
Handle RPS request from the client. More... | |
static void | handle_client_view_cancel (void *cls, const struct GNUNET_MessageHeader *msg) |
Handle the cancellation of the view updates. More... | |
static void | handle_client_stream_request (void *cls, const struct GNUNET_RPS_CS_DEBUG_StreamRequest *msg) |
Handle RPS request for biased stream from the client. More... | |
static void | handle_client_stream_cancel (void *cls, const struct GNUNET_MessageHeader *msg) |
Handles the cancellation of the stream of biased peer ids. More... | |
static void | handle_client_start_sub (void *cls, const struct GNUNET_RPS_CS_SubStartMessage *msg) |
Create and start a Sub. More... | |
static void | handle_client_stop_sub (void *cls, const struct GNUNET_RPS_CS_SubStopMessage *msg) |
Destroy the Sub. More... | |
static struct GNUNET_TIME_Relative | compute_rand_delay (struct GNUNET_TIME_Relative mean, unsigned int spread) |
Compute a random delay. More... | |
static void | send_pull_request (struct PeerContext *peer_ctx) |
Send single pull request. More... | |
static void | send_push (struct PeerContext *peer_ctx) |
Send single push. More... | |
void | init_peer_cb (void *cls, const struct GNUNET_PeerIdentity *peer, int tunnel, unsigned int n_paths, unsigned int best_path) |
This is called from GNUNET_CADET_get_peers(). More... | |
static int | valid_peers_iterator (void *cls, const struct GNUNET_PeerIdentity *peer) |
Iterator function over stored, valid peers. More... | |
void | process_peerinfo_peers (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg) |
Iterator over peers from peerinfo. More... | |
static void | shutdown_task (void *cls) |
Task run during shutdown. More... | |
static void * | client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq) |
Handle client connecting to the service. More... | |
static void | client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls) |
Callback called when a client disconnected from the service. More... | |
static void | error_cb (void *cls) |
static void | sync_cb (void *cls) |
static void | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service) |
Handle random peer sampling clients. More... | |
GNUNET_SERVICE_MAIN (GNUNET_OS_project_data_gnunet(), "rps", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(client_seed, GNUNET_MESSAGE_TYPE_RPS_CS_SEED, struct GNUNET_RPS_CS_SeedMessage, NULL), GNUNET_MQ_hd_fixed_size(client_view_request, GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_REQUEST, struct GNUNET_RPS_CS_DEBUG_ViewRequest, NULL), GNUNET_MQ_hd_fixed_size(client_view_cancel, GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_CANCEL, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_fixed_size(client_stream_request, GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_REQUEST, struct GNUNET_RPS_CS_DEBUG_StreamRequest, NULL), GNUNET_MQ_hd_fixed_size(client_stream_cancel, GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_CANCEL, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_fixed_size(client_start_sub, GNUNET_MESSAGE_TYPE_RPS_CS_SUB_START, struct GNUNET_RPS_CS_SubStartMessage, NULL), GNUNET_MQ_hd_fixed_size(client_stop_sub, GNUNET_MESSAGE_TYPE_RPS_CS_SUB_STOP, struct GNUNET_RPS_CS_SubStopMessage, NULL), GNUNET_MQ_handler_end()) | |
Define "main" method using service macro. More... | |
Variables | |
static const struct GNUNET_CONFIGURATION_Handle * | cfg |
Our configuration. More... | |
struct GNUNET_STATISTICS_Handle * | stats |
Handle to the statistics service. More... | |
struct GNUNET_CADET_Handle * | cadet_handle |
Handler to CADET. More... | |
struct GNUNET_CORE_Handle * | core_handle |
Handle to CORE. More... | |
struct GNUNET_CONTAINER_MultiPeerMap * | map_single_hop |
PeerMap to keep track of connected peers. More... | |
static struct GNUNET_PeerIdentity | own_identity |
Our own identity. More... | |
static float | alpha |
Percentage of total peer number in the view to send random PUSHes to. More... | |
static float | beta |
Percentage of total peer number in the view to send random PULLs to. More... | |
static struct GNUNET_NSE_Handle * | nse |
Handler to NSE. More... | |
static struct GNUNET_PEERSTORE_Handle * | peerstore |
Handle to the PEERSTORE service. More... | |
static struct GNUNET_PEERSTORE_Monitor * | peerstore_notify |
Our peerstore notification context. More... | |
static struct Sub * | msub |
Main Sub. More... | |
static const uint32_t | num_valid_peers_max = UINT32_MAX |
Maximum number of valid peers to keep. More... | |
struct ClientContext * | cli_ctx_head |
DLL with all clients currently connected to us. More... | |
struct ClientContext * | cli_ctx_tail |
rps service implementation
Definition in file gnunet-service-rps.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log (kind, __VA_ARGS__) |
Definition at line 45 of file gnunet-service-rps.c.
#define SET_PEER_FLAG | ( | peer_ctx, | |
mask | |||
) | ((peer_ctx->peer_flags) |= (mask)) |
Set a peer flag of given peer context.
Definition at line 64 of file gnunet-service-rps.c.
#define check_peer_flag_set | ( | peer_ctx, | |
mask | |||
) | ((peer_ctx->peer_flags) & (mask) ? GNUNET_YES : GNUNET_NO) |
Get peer flag of given peer context.
Definition at line 69 of file gnunet-service-rps.c.
#define UNSET_PEER_FLAG | ( | peer_ctx, | |
mask | |||
) | ((peer_ctx->peer_flags) &= ~(mask)) |
Unset flag of given peer context.
Definition at line 75 of file gnunet-service-rps.c.
#define check_channel_flag_set | ( | channel_flags, | |
mask | |||
) | ((*channel_flags) & (mask) ? GNUNET_YES : GNUNET_NO) |
Get channel flag of given channel context.
Definition at line 80 of file gnunet-service-rps.c.
#define unset_channel_flag | ( | channel_flags, | |
mask | |||
) | ((*channel_flags) &= ~(mask)) |
Unset flag of given channel context.
Definition at line 86 of file gnunet-service-rps.c.
#define HISTOGRAM_FILE_SLOTS 32 |
This number determines the number of slots for files that represent histograms.
Definition at line 289 of file gnunet-service-rps.c.
#define SIZE_DUMP_FILE (HISTOGRAM_FILE_SLOTS * 5) + 1 |
The size (in bytes) a file needs to store the histogram.
Per slot: 1 newline, up to 4 chars, Additionally: 1 null termination
Definition at line 297 of file gnunet-service-rps.c.
|
static |
Send out PUSHes and PULLs, possibly update #view, samplers.
This is executed regylary.
cls | Closure - Sub |
Definition at line 4285 of file gnunet-service-rps.c.
References alpha, beta, check_peer_flag(), clean_peer(), clients_notify_stream_peer(), clients_notify_view_update(), compute_rand_delay(), CustomPeerMap_clear(), CustomPeerMap_get_peer_by_index(), CustomPeerMap_size(), do_round(), Sub::do_round_task, get_peer_ctx(), GNUNET_array_grow, GNUNET_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_random_permute(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_i2s(), GNUNET_i2s_full(), GNUNET_memcpy, GNUNET_MIN, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), hist_update(), HISTOGRAM_FILE_SLOTS, insert_in_sampler(), insert_in_view(), LOG, msub, Sub::num_rounds, Sub::peer_map, Peers_PULL_REPLY_PENDING, Sub::pull_map, Sub::push_delta, Sub::push_map, Sub::push_recv, rem_from_list(), Sub::round_interval, RPS_sampler_get_n_rand_peers(), Sub::sampler, send_pull_request(), send_push(), stats, to_file, Sub::view, View_clear(), View_get_as_array(), View_size(), and Sub::view_size_est_need.
Referenced by do_round(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_relative2s(), and new_sub().
|
static |
Get the PeerContext associated with a peer.
peer_map | The peer map containing the context |
peer | the peer id |
Definition at line 617 of file gnunet-service-rps.c.
References ctx, GNUNET_assert, GNUNET_CONTAINER_multipeermap_contains(), GNUNET_CONTAINER_multipeermap_get(), GNUNET_YES, and ret.
Referenced by check_connected(), check_peer_flag(), clean_peer(), create_or_get_peer_ctx(), do_round(), got_peer(), handle_inbound_channel(), handle_peer_pull_reply(), insert_in_view(), issue_peer_online_check(), peermap_clear_iterator(), and remove_peer().
|
static |
Check whether we have information about the given peer.
FIXME probably deprecated. Make this the new _online.
peer_map | The peer map to check for the existence of peer |
peer | peer in question |
Definition at line 643 of file gnunet-service-rps.c.
References GNUNET_CONTAINER_multipeermap_contains(), and GNUNET_NO.
Referenced by check_connected(), check_peer_flag(), check_sending_channel_exists(), check_sending_channel_needed(), create_or_get_peer_ctx(), create_peer_ctx(), destroy_sending_channel(), handle_peer_pull_reply(), handle_peer_pull_request(), handle_peer_push(), hist_update(), indicate_sending_intention(), insert_peer(), remove_peer(), and schedule_operation().
|
static |
Create a new PeerContext and insert it into the peer map.
sub | The Sub this context belongs to. |
peer | the peer to create the PeerContext for |
Definition at line 666 of file gnunet-service-rps.c.
References check_peer_known(), ctx, GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_set(), msub, Sub::peer_map, ret, stats, and PeerContext::sub.
Referenced by create_or_get_peer_ctx(), and insert_peer().
|
static |
Create or get a PeerContext.
sub | The Sub to which the created context belongs to |
peer | the peer to get the associated context to |
Definition at line 700 of file gnunet-service-rps.c.
References check_peer_known(), create_peer_ctx(), get_peer_ctx(), GNUNET_NO, Sub::peer_map, and PeerContext::sub.
Referenced by handle_inbound_channel().
|
static |
Check whether we have a connection to this peer.
Also sets the Peers_ONLINE flag accordingly
peer_ctx | Context of the peer of which connectivity is to be checked |
Definition at line 722 of file gnunet-service-rps.c.
References check_peer_known(), get_peer_ctx(), GNUNET_NO, GNUNET_YES, PeerContext::peer_id, Sub::peer_map, Peers_ONLINE, PeerContext::recv_channel_ctx, PeerContext::send_channel_ctx, SET_PEER_FLAG, PeerContext::sub, and UNSET_PEER_FLAG.
Referenced by destroy_sending_channel().
|
static |
Iterator function for get_random_peer_from_peermap.
Implements GNUNET_CONTAINER_PeerMapIterator. Decreases the index until the index is null. Then returns the current peer.
cls | the GetRandPeerIteratorCls containing index and peer |
peer | current peer |
value | unused |
Definition at line 780 of file gnunet-service-rps.c.
References GNUNET_NO, GNUNET_YES, GetRandPeerIteratorCls::index, GetRandPeerIteratorCls::peer, and value.
Referenced by get_random_peer_from_peermap().
|
static |
Get a random peer from peer_map.
valid_peers | Peer map containing valid peers from which to select a random one |
Definition at line 807 of file gnunet-service-rps.c.
References get_rand_peer_iterator(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_free, GNUNET_new, GetRandPeerIteratorCls::index, GetRandPeerIteratorCls::peer, and ret.
Referenced by add_valid_peer().
|
static |
Add a given peer to valid peers.
If valid peers are already num_valid_peers_max, delete a peer previously.
peer | The peer that is added to the valid peers. |
valid_peers | Peer map of valid peers to which to add the peer |
Definition at line 837 of file gnunet-service-rps.c.
References get_random_peer_from_peermap(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_remove_all(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_YES, msub, num_valid_peers_max, ret, stats, and Sub::valid_peers.
Referenced by handle_inbound_channel(), mq_online_check_successful(), and restore_valid_peers().
|
static |
Remove a pending message from the respective DLL.
pending_msg | the pending message to remove |
cancel | whether to cancel the pending message, too |
Definition at line 1091 of file gnunet-service-rps.c.
References GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, PendingMessage::peer_ctx, PeerContext::pending_messages_head, and PeerContext::pending_messages_tail.
Referenced by destroy_peer(), mq_notify_sent_cb(), mq_online_check_successful(), and set_peer_online().
|
static |
Set the peer flag to living and call the pending operations on this peer.
Also adds peer to #valid_peers.
peer_ctx | the PeerContext of the peer to set online |
Definition at line 877 of file gnunet-service-rps.c.
References GNUNET_array_grow, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_YES, LOG, PeerContext::num_pending_ops, PeerContext::online_check_pending, PeerPendingOp::op, PeerPendingOp::op_cls, PeerContext::peer_id, Peers_ONLINE, PeerContext::pending_ops, remove_pending_message(), and SET_PEER_FLAG.
Referenced by handle_inbound_channel(), and mq_online_check_successful().
|
static |
This is called when a channel is destroyed.
Removes peer completely from our knowledge if the send_channel was destroyed Otherwise simply delete the recv_channel Also check if the knowledge about this peer is still needed. If not, remove this peer from our knowledge.
cls | The closure - Context to the channel |
channel | The channel being closed |
Definition at line 2834 of file gnunet-service-rps.c.
References ChannelCtx::channel, check_sending_channel_needed(), GNUNET_YES, ChannelCtx::peer_ctx, PeerContext::peer_id, remove_channel_ctx(), remove_peer(), PeerContext::send_channel_ctx, and PeerContext::sub.
Referenced by get_channel(), and new_sub().
|
static |
Handle a CHECK_LIVE message from another peer.
This does nothing. But without calling GNUNET_CADET_receive_done() the channel is blocked for all other communication.
cls | Closure - Context of channel |
msg | Message - unused |
Definition at line 3529 of file gnunet-service-rps.c.
References ChannelCtx::channel, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_NO, GNUNET_STATISTICS_update(), LOG, msg, msub, ChannelCtx::peer_ctx, PeerContext::peer_id, stats, and PeerContext::sub.
|
static |
Handle a PUSH message from another peer.
Check the proof of work and store the PeerID in the temporary list for pushed PeerIDs.
cls | Closure - Context of channel |
msg | Message - unused |
Definition at line 3561 of file gnunet-service-rps.c.
References ChannelCtx::channel, check_peer_known(), CustomPeerMap_put(), GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_multipeermap_contains(), GNUNET_CONTAINER_multipeermap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), LOG, map_single_hop, msg, msub, ChannelCtx::peer_ctx, PeerContext::peer_id, Sub::peer_map, Sub::push_map, stats, and PeerContext::sub.
|
static |
Handle PULL REQUEST request message from another peer.
Reply with the view of PeerIDs.
cls | Closure - Context of channel |
msg | Message - unused |
Definition at line 3637 of file gnunet-service-rps.c.
References ChannelCtx::channel, check_peer_known(), GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_CONTAINER_multipeermap_contains(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_memcmp, GNUNET_NO, GNUNET_STATISTICS_update(), LOG, map_single_hop, msg, msub, ChannelCtx::peer_ctx, PeerContext::peer_id, Sub::peer_map, send_pull_reply(), stats, PeerContext::sub, Sub::view, View_get_as_array(), and View_size().
|
static |
Check whether we sent a corresponding request and whether this reply is the first one.
cls | Closure - Context of channel |
msg | Message containing the replied peers |
Definition at line 3700 of file gnunet-service-rps.c.
References check_peer_flag(), GNUNET_break_op, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_YES, LOG, msg, msub, ChannelCtx::peer_ctx, PeerContext::peer_id, Sub::peer_map, Peers_PULL_REPLY_PENDING, GNUNET_MessageHeader::size, stats, and PeerContext::sub.
|
static |
Handle PULL REPLY message from another peer.
cls | Closure |
msg | The message header |
Definition at line 3752 of file gnunet-service-rps.c.
References ChannelCtx::channel, check_peer_known(), check_peer_valid(), clean_peer(), CustomPeerMap_put(), get_peer_ctx(), GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_multipeermap_contains(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, insert_in_pull_map(), insert_peer(), issue_peer_online_check(), LOG, map_single_hop, msg, msub, Sub::num_rounds, ChannelCtx::peer_ctx, PeerContext::peer_id, Sub::peer_map, peers, Peers_PULL_REPLY_PENDING, Sub::pull_delays, Sub::pull_map, PeerContext::round_pull_req, schedule_operation(), stats, PeerContext::sub, UNSET_PEER_FLAG, and Sub::valid_peers.
|
static |
Allocate memory for a new channel context and insert it into DLL.
peer_ctx | context of the according peer |
Definition at line 945 of file gnunet-service-rps.c.
References GNUNET_new, and ChannelCtx::peer_ctx.
Referenced by get_channel(), and handle_inbound_channel().
|
static |
Free memory and NULL pointers.
channel_ctx | The channel context. |
Definition at line 961 of file gnunet-service-rps.c.
References ChannelCtx::destruction_task, GNUNET_free, GNUNET_SCHEDULER_cancel(), PeerContext::mq, ChannelCtx::peer_ctx, PeerContext::recv_channel_ctx, and PeerContext::send_channel_ctx.
Referenced by cleanup_destroyed_channel(), and destroy_channel().
struct GNUNET_CADET_Channel * get_channel | ( | struct PeerContext * | peer_ctx | ) |
Get the channel of a peer.
If not existing, create.
peer_ctx | Context of the peer of which to get the channel |
Definition at line 993 of file gnunet-service-rps.c.
References add_channel_ctx(), cadet_handle, ChannelCtx::channel, cleanup_destroyed_channel(), GNUNET_assert, GNUNET_CADET_channel_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE, GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REPLY, GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST, GNUNET_MESSAGE_TYPE_RPS_PP_PUSH, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, Sub::hash, LOG, PeerContext::peer_id, PeerContext::send_channel_ctx, and PeerContext::sub.
Referenced by get_mq(), and indicate_sending_intention().
|
static |
Get the message queue (GNUNET_MQ_Handle) of a specific peer.
If we already have a message queue open to this client, simply return it, otherwise create one.
peer_ctx | Context of the peer of which to get the mq |
Definition at line 1048 of file gnunet-service-rps.c.
References get_channel(), GNUNET_CADET_get_mq(), and PeerContext::mq.
Referenced by check_peer_online(), and send_message().
|
static |
Add an envelope to a message passed to mq to list of pending messages.
peer_ctx | Context of the peer for which to insert the envelope |
ev | envelope to the message |
type | type of the message to be sent |
Definition at line 1067 of file gnunet-service-rps.c.
References PendingMessage::ev, GNUNET_CONTAINER_DLL_insert, GNUNET_new, PendingMessage::peer_ctx, PeerContext::pending_messages_head, PeerContext::pending_messages_tail, type, and PendingMessage::type.
Referenced by check_peer_online(), and send_message().
|
static |
This is called in response to the first message we sent as a online check.
cls | PeerContext of peer with pending online check |
Definition at line 1118 of file gnunet-service-rps.c.
References add_valid_peer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_YES, LOG, PeerContext::online_check_pending, PeerContext::peer_id, remove_pending_message(), set_peer_online(), PeerContext::sub, and Sub::valid_peers.
Referenced by check_peer_online().
|
static |
Issue a check whether peer is online.
peer_ctx | the context of the peer |
Definition at line 1141 of file gnunet-service-rps.c.
References get_mq(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE, GNUNET_MQ_msg_header, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_NO, GNUNET_STATISTICS_update(), insert_pending_message(), LOG, mq, mq_online_check_successful(), msub, PeerContext::online_check_pending, PeerContext::peer_id, stats, and PeerContext::sub.
Referenced by issue_peer_online_check().
|
static |
Check whether function of type PeerOp was already scheduled.
The array with pending operations will probably never grow really big, so iterating over it should be ok.
peer_ctx | Context of the peer to check for the operation |
peer_op | the operation (PeerOp) on the peer |
Definition at line 1181 of file gnunet-service-rps.c.
References GNUNET_NO, GNUNET_YES, PeerContext::num_pending_ops, PeerPendingOp::op, and PeerContext::pending_ops.
Referenced by schedule_operation().
|
static |
Callback for scheduler to destroy a channel.
channel_ctx | Context of the channel |
Definition at line 1199 of file gnunet-service-rps.c.
References ChannelCtx::channel, ChannelCtx::destruction_task, GNUNET_assert, GNUNET_CADET_channel_destroy(), GNUNET_SCHEDULER_cancel(), and remove_channel_ctx().
Referenced by destroy_channel_cb(), destroy_sending_channel(), and handle_inbound_channel().
|
static |
Destroy a cadet channel.
This satisfies the function signature of GNUNET_SCHEDULER_TaskCallback.
cls |
Definition at line 1224 of file gnunet-service-rps.c.
References destroy_channel(), and ChannelCtx::destruction_task.
Referenced by schedule_channel_destruction().
|
static |
Schedule the destruction of a channel for immediately afterwards.
In case a channel is to be destroyed from within the callback to the destruction of another channel (send channel), we cannot call GNUNET_CADET_channel_destroy directly, but need to use this scheduling construction.
channel_ctx | channel to be destroyed. |
Definition at line 1244 of file gnunet-service-rps.c.
References ChannelCtx::channel, destroy_channel_cb(), ChannelCtx::destruction_task, GNUNET_assert, and GNUNET_SCHEDULER_add_now().
Referenced by destroy_peer().
|
static |
Remove peer.
peer_ctx | Context of the peer to be destroyed |
Definition at line 1270 of file gnunet-service-rps.c.
References GNUNET_array_grow, GNUNET_assert, GNUNET_CONTAINER_multipeermap_contains(), GNUNET_CONTAINER_multipeermap_remove_all(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_YES, LOG, PeerContext::mq, msub, PeerContext::num_pending_ops, PeerContext::online_check_pending, ChannelCtx::peer_ctx, PeerContext::peer_id, Sub::peer_map, Peers_ONLINE, Peers_TO_DESTROY, PeerContext::pending_messages_head, PeerContext::pending_ops, PeerContext::recv_channel_ctx, remove_pending_message(), schedule_channel_destruction(), PeerContext::send_channel_ctx, SET_PEER_FLAG, stats, PeerContext::sub, PendingMessage::type, and UNSET_PEER_FLAG.
Referenced by peermap_clear_iterator(), and remove_peer().
|
static |
Iterator over hash map entries.
Deletes all contexts of peers.
cls | closure |
key | current public key |
value | value in the hash map |
Definition at line 1377 of file gnunet-service-rps.c.
References destroy_peer(), get_peer_ctx(), GNUNET_YES, key, Sub::peer_map, and value.
Referenced by peers_terminate().
|
static |
This is called once a message is sent.
Removes the pending message
cls | type of the message that was sent |
Definition at line 1398 of file gnunet-service-rps.c.
References GNUNET_CONTAINER_multipeermap_contains(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_STATISTICS_update(), LOG, map_single_hop, msub, PendingMessage::peer_ctx, PeerContext::peer_id, remove_pending_message(), stats, PeerContext::sub, and PendingMessage::type.
Referenced by send_message().
|
static |
Iterator function for store_valid_peers.
Implements GNUNET_CONTAINER_PeerMapIterator. Writes single peer to disk.
cls | the file handle to write to. |
peer | current peer |
value | unused |
Definition at line 1443 of file gnunet-service-rps.c.
References GNUNET_assert, GNUNET_DISK_file_write(), GNUNET_i2s_full(), GNUNET_snprintf(), GNUNET_YES, ret, size, and value.
Referenced by store_valid_peers().
|
static |
Store the peers currently in #valid_peers to disk.
sub | Sub for which to store the valid peers |
Definition at line 1477 of file gnunet-service-rps.c.
References Sub::filename_valid_peers, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_WRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, LOG, ret, store_peer_presistently_iterator(), and Sub::valid_peers.
Referenced by peers_terminate().
|
static |
Convert string representation of peer id to peer id.
Counterpart to GNUNET_i2s_full.
string_repr | The string representation of the peer id |
Definition at line 1538 of file gnunet-service-rps.c.
References GNUNET_break, GNUNET_CRYPTO_eddsa_public_key_from_string(), GNUNET_ERROR_TYPE_WARNING, GNUNET_new, GNUNET_OK, LOG, GNUNET_PeerIdentity::public_key, and ret.
Referenced by restore_valid_peers().
|
static |
Restore the peers on disk to #valid_peers.
sub | Sub for which to restore the valid peers |
Definition at line 1580 of file gnunet-service-rps.c.
References add_valid_peer(), Sub::filename_valid_peers, GNUNET_assert, GNUNET_CONTAINER_multipeermap_size(), GNUNET_DISK_file_close(), GNUNET_DISK_file_handle_size(), GNUNET_DISK_file_open(), GNUNET_DISK_file_read(), GNUNET_DISK_file_test(), GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_i2s_full(), GNUNET_malloc, GNUNET_OK, GNUNET_strndup, LOG, num_peers, s2i_full(), and Sub::valid_peers.
Referenced by run().
|
static |
Delete storage of peers that was created with #initialise_peers ()
sub | Sub for which the storage is deleted |
Definition at line 1647 of file gnunet-service-rps.c.
References Sub::filename_valid_peers, GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_SYSERR, LOG, Sub::peer_map, peermap_clear_iterator(), store_valid_peers(), and Sub::valid_peers.
Referenced by destroy_sub().
|
static |
Iterator over #valid_peers hash map entries.
cls | Closure that contains iterator function and closure |
peer | current peer id |
value | value in the hash map - unused |
Definition at line 1678 of file gnunet-service-rps.c.
References PeersIteratorCls::cls, PeersIteratorCls::iterator, and value.
Referenced by get_valid_peers().
|
static |
Get all currently known, valid peer ids.
valid_peers | Peer map containing the valid peers in question |
iterator | function to call on each peer id |
it_cls | extra argument to iterator |
Definition at line 1700 of file gnunet-service-rps.c.
References PeersIteratorCls::cls, GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_free, GNUNET_new, PeersIteratorCls::iterator, ret, and valid_peer_iterator().
Referenced by run().
|
static |
Add peer to known peers.
This function is called on new peer_ids from 'external' sources (client seed, cadet get_peers(), ...)
sub | Sub with the peer map that the peer will be added to |
peer | the new GNUNET_PeerIdentity |
Definition at line 1731 of file gnunet-service-rps.c.
References check_peer_known(), create_peer_ctx(), GNUNET_NO, GNUNET_YES, and Sub::peer_map.
Referenced by handle_peer_pull_reply(), and issue_peer_online_check().
|
static |
Check whether flags on a peer are set.
peer_map | Peer map that is expected to contain the peer |
peer | the peer to check the flag of |
flags | the flags to check |
Definition at line 1755 of file gnunet-service-rps.c.
References check_peer_flag_set, check_peer_known(), get_peer_ctx(), GNUNET_NO, and GNUNET_SYSERR.
Referenced by check_peer_pull_reply(), check_sending_channel_needed(), do_round(), insert_in_view(), issue_peer_online_check(), and send_pull_request().
|
static |
Try connecting to a peer to see whether it is online.
If not known yet, insert into known peers
sub | Sub which would contain the peer |
peer | the peer whose online is to be checked |
Definition at line 1781 of file gnunet-service-rps.c.
References check_peer_flag(), check_peer_online(), get_peer_ctx(), GNUNET_NO, GNUNET_YES, insert_peer(), PeerContext::online_check_pending, Sub::peer_map, Peers_ONLINE, and PeerContext::sub.
Referenced by got_peer(), handle_peer_pull_reply(), insert_in_sampler(), and insert_in_view().
|
static |
Check if peer is removable.
Check if
peer_ctx | Context of the peer in question |
Definition at line 1812 of file gnunet-service-rps.c.
References check_peer_flag_set, GNUNET_CONTAINER_multipeermap_contains(), GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, PeerContext::peer_id, Sub::peer_map, Peers_PULL_REPLY_PENDING, PeerContext::pending_messages_head, PeerContext::recv_channel_ctx, and PeerContext::sub.
Referenced by clean_peer().
|
static |
Check whether peer is actually a peer.
A valid peer is a peer that we know exists eg. we were connected to once.
valid_peers | Peer map that would contain the peer |
peer | peer in question |
Definition at line 1843 of file gnunet-service-rps.c.
References GNUNET_CONTAINER_multipeermap_contains().
Referenced by handle_peer_pull_reply().
|
static |
Indicate that we want to send to the other peer.
This establishes a sending channel
peer_ctx | Context of the target peer |
Definition at line 1858 of file gnunet-service-rps.c.
References check_peer_known(), get_channel(), GNUNET_assert, GNUNET_YES, PeerContext::peer_id, Sub::peer_map, and PeerContext::sub.
Referenced by insert_in_view().
|
static |
Check whether other peer has the intention to send/opened channel towars us.
peer_ctx | Context of the peer in question |
Definition at line 1876 of file gnunet-service-rps.c.
References GNUNET_NO, GNUNET_YES, and PeerContext::recv_channel_ctx.
Referenced by clean_peer(), and handle_inbound_channel().
|
static |
Handle the channel a peer opens to us.
cls | The closure - Sub |
channel | The channel the peer wants to establish |
initiator | The peer's peer ID |
Definition at line 1897 of file gnunet-service-rps.c.
References add_channel_ctx(), add_valid_peer(), ChannelCtx::channel, check_peer_send_intention(), create_or_get_peer_ctx(), destroy_channel(), get_peer_ctx(), GNUNET_assert, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_YES, LOG, PeerContext::peer_id, Sub::peer_map, PeerContext::recv_channel_ctx, set_peer_online(), PeerContext::sub, and Sub::valid_peers.
Referenced by new_sub().
|
static |
Check whether a sending channel towards the given peer exists.
peer_ctx | Context of the peer in question |
Definition at line 1941 of file gnunet-service-rps.c.
References check_peer_known(), GNUNET_NO, GNUNET_YES, PeerContext::peer_id, Sub::peer_map, PeerContext::send_channel_ctx, and PeerContext::sub.
Referenced by check_sending_channel_needed().
|
static |
Destroy the send channel of a peer e.g.
stop indicating a sending intention to another peer
peer_ctx | Context to the peer |
Definition at line 1965 of file gnunet-service-rps.c.
References check_connected(), check_peer_known(), destroy_channel(), GNUNET_NO, GNUNET_YES, PeerContext::peer_id, Sub::peer_map, PeerContext::send_channel_ctx, and PeerContext::sub.
Referenced by clean_peer().
|
static |
Send a message to another peer.
Keeps track about pending messages so they can be properly removed when the peer is destroyed.
peer_ctx | Context of the peer to which the message is to be sent |
ev | envelope of the message |
type | type of the message |
Definition at line 1993 of file gnunet-service-rps.c.
References get_mq(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), insert_pending_message(), mq, mq_notify_sent_cb(), PeerContext::peer_id, and type.
Referenced by send_pull_reply(), send_pull_request(), and send_push().
|
static |
Schedule a operation on given peer.
Avoids scheduling an operation twice.
peer_ctx | Context of the peer for which to schedule the operation |
peer_op | the operation to schedule |
cls | Closure to peer_op |
Definition at line 2026 of file gnunet-service-rps.c.
References check_operation_scheduled(), check_peer_known(), GNUNET_array_append, GNUNET_assert, GNUNET_NO, GNUNET_YES, PeerContext::num_pending_ops, PeerPendingOp::op, PeerPendingOp::op_cls, PeerContext::peer_id, Sub::peer_map, PeerContext::pending_ops, and PeerContext::sub.
Referenced by got_peer(), handle_peer_pull_reply(), and insert_in_view().
|
static |
Print peerlist to log.
Definition at line 2146 of file gnunet-service-rps.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), list, and LOG.
Referenced by handle_client_seed().
|
static |
Remove peer from list.
Definition at line 2168 of file gnunet-service-rps.c.
References GNUNET_array_grow, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_memcmp, and LOG.
Referenced by do_round().
|
static |
Insert PeerID in #view.
Called once we know a peer is online. Implements PeerOp
Called once we know a peer is online. Implements PeerOp
cls | Closure - Sub with view to insert peer into |
peer | the peer to insert |
Definition at line 2596 of file gnunet-service-rps.c.
References clients_notify_stream_peer(), GNUNET_OK, and insert_in_view().
Referenced by got_peer(), and insert_in_view().
|
static |
Insert PeerID in #view.
Called once we know a peer is online.
sub | Sub in with the view to insert in |
peer | the peer to insert |
Definition at line 2224 of file gnunet-service-rps.c.
References check_peer_flag(), get_peer_ctx(), GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_SYSERR, indicate_sending_intention(), insert_in_view_op(), issue_peer_online_check(), msub, Sub::peer_map, Peers_ONLINE, ret, schedule_operation(), stats, PeerContext::sub, Sub::view, View_put(), and View_size().
Referenced by do_round(), hist_update(), and insert_in_view_op().
|
static |
Send view to client.
cli_ctx | the context of the client |
view_array | the peerids of the view as array (can be empty) |
view_size | the size of the view array (can be 0) |
Definition at line 2262 of file gnunet-service-rps.c.
References GNUNET_memcpy, GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_REPLY, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), ClientContext::mq, msub, GNUNET_RPS_CS_DEBUG_ViewReply::num_peers, ClientContext::sub, Sub::view, View_get_as_array(), and View_size().
Referenced by clients_notify_view_update(), and handle_client_view_request().
|
static |
Send peer from biased stream to client.
TODO merge with send_view, parameterise
cli_ctx | the context of the client |
view_array | the peerids of the view as array (can be empty) |
view_size | the size of the view array (can be 0) |
Definition at line 2302 of file gnunet-service-rps.c.
References GNUNET_assert, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_REPLY, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), ClientContext::mq, GNUNET_RPS_CS_DEBUG_StreamReply::num_peers, num_peers, and peers.
Referenced by clients_notify_stream_peer().
|
static |
sends updates to clients that are interested
sub | Sub for which to notify clients |
Definition at line 2329 of file gnunet-service-rps.c.
References cli_ctx_head, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, ClientContext::next, num_peers, send_view(), Sub::view, View_get_as_array(), View_size(), and ClientContext::view_updates_left.
Referenced by do_round(), and hist_update().
|
static |
sends updates to clients that are interested
num_peers | Number of peers to send |
peers | the array of peers to send |
Definition at line 2379 of file gnunet-service-rps.c.
References cli_ctx_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_YES, LOG, msub, ClientContext::next, num_peers, peers, send_stream_peers(), ClientContext::stream_update, and ClientContext::sub.
Referenced by do_round(), hist_update(), and insert_in_view_op().
|
static |
Put random peer from sampler into the view as history update.
ids | Array of Peers to insert into view |
num_peers | Number of peers to insert |
cls | Closure - The Sub for which this is to be done |
Definition at line 2411 of file gnunet-service-rps.c.
References check_peer_known(), clients_notify_stream_peer(), clients_notify_view_update(), GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s_full(), GNUNET_OK, GNUNET_YES, insert_in_view(), LOG, num_peers, Sub::peer_map, and to_file.
Referenced by do_round().
|
static |
Wrapper around RPS_sampler_resize()
If we do not have enough sampler elements, double current sampler size If we have more than enough sampler elements, halv current sampler size
sampler | The sampler to resize |
new_size | New size to which to resize |
Definition at line 2452 of file gnunet-service-rps.c.
References GNUNET_ERROR_TYPE_DEBUG, LOG, RPS_sampler_get_size(), RPS_sampler_resize(), and Sub::sampler.
Referenced by adapt_sizes().
|
static |
Send a PULL REPLY to peer_id.
peer_ctx | Context of the peer to send the reply to |
peer_ids | the peers to send to peer_id |
num_peer_ids | the number of peers to send to peer_id |
Definition at line 2521 of file gnunet-service-rps.c.
References GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REPLY, GNUNET_MQ_msg_extra, GNUNET_NO, GNUNET_STATISTICS_update(), LOG, msub, GNUNET_RPS_P2P_PullReplyMessage::num_peers, PeerContext::peer_id, send_message(), stats, and PeerContext::sub.
Referenced by handle_peer_pull_request().
|
static |
Insert PeerID in #pull_map.
Called once we know a peer is online.
Definition at line 2577 of file gnunet-service-rps.c.
References CustomPeerMap_put(), and Sub::pull_map.
Referenced by handle_peer_pull_reply().
|
static |
Update sampler with given PeerID.
Implements PeerOp
Definition at line 2618 of file gnunet-service-rps.c.
References GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), issue_peer_online_check(), LOG, msub, Sub::num_observed_peers, Sub::observed_unique_peers, RPS_sampler_count_id(), RPS_sampler_update(), Sub::sampler, stats, and to_file.
Referenced by do_round(), and got_peer().
|
static |
This is called on peers from external sources (cadet, peerinfo, ...) If the peer is not known, online check is issued and it is scheduled to be inserted in sampler and view.
"External sources" refer to every source except the gossip.
sub | Sub for which peer was received |
peer | peer to insert/peer received |
Definition at line 2677 of file gnunet-service-rps.c.
References get_peer_ctx(), GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, insert_in_sampler(), insert_in_view_op(), issue_peer_online_check(), msub, Sub::peer_map, schedule_operation(), and stats.
Referenced by handle_client_seed(), init_peer_cb(), process_peerinfo_peers(), and valid_peers_iterator().
|
static |
Checks if there is a sending channel and if it is needed.
peer_ctx | Context of the peer to check |
Definition at line 2706 of file gnunet-service-rps.c.
References check_peer_flag(), check_peer_known(), check_sending_channel_exists(), CustomPeerMap_contains_peer(), GNUNET_NO, GNUNET_YES, PeerContext::peer_id, Sub::peer_map, Peers_PULL_REPLY_PENDING, Sub::pull_map, Sub::push_map, RPS_sampler_count_id(), Sub::sampler, PeerContext::sub, Sub::view, and View_contains_peer().
Referenced by clean_peer(), and cleanup_destroyed_channel().
|
static |
remove peer from our knowledge, the view, push and pull maps and samplers.
sub | Sub with the data structures the peer is to be removed from |
peer | the peer to remove |
Definition at line 2744 of file gnunet-service-rps.c.
References check_peer_known(), CustomPeerMap_remove_peer(), destroy_peer(), get_peer_ctx(), GNUNET_YES, Sub::peer_map, Sub::pull_map, Sub::push_map, RPS_sampler_reinitialise_by_value(), Sub::sampler, Sub::view, and View_remove_peer().
Referenced by clean_peer(), and cleanup_destroyed_channel().
|
static |
Remove data that is not needed anymore.
If the sending channel is no longer needed it is destroyed.
sub | Sub in which the current peer is to be cleaned |
peer | the peer whose data is about to be cleaned |
Definition at line 2776 of file gnunet-service-rps.c.
References check_peer_send_intention(), check_removable(), check_sending_channel_needed(), CustomPeerMap_contains_peer(), destroy_sending_channel(), get_peer_ctx(), GNUNET_CONTAINER_multipeermap_contains(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_memcmp, GNUNET_NO, GNUNET_YES, LOG, Sub::peer_map, Sub::pull_map, Sub::push_map, remove_peer(), RPS_sampler_count_id(), Sub::sampler, Sub::view, and View_contains_peer().
Referenced by do_round(), and handle_peer_pull_reply().
struct Sub * new_sub | ( | const struct GNUNET_HashCode * | hash, |
uint32_t | sampler_size, | ||
struct GNUNET_TIME_Relative | round_interval | ||
) |
Create a new Sub.
hash | Hash of value shared among rps instances on other hosts that defines a subgroup to sample from. |
sampler_size | Size of the sampler |
round_interval | Interval (in average) between two rounds |
Definition at line 2880 of file gnunet-service-rps.c.
References cadet_handle, Sub::cadet_port, cfg, cleanup_destroyed_channel(), CustomPeerMap_create(), do_round(), Sub::do_round_task, Sub::filename_valid_peers, GNUNET_APPLICATION_PORT_RPS, GNUNET_asprintf(), GNUNET_assert, GNUNET_CADET_open_port(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONTAINER_multipeermap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_h2s_full(), GNUNET_log_config_missing(), GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE, GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REPLY, GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST, GNUNET_MESSAGE_TYPE_RPS_PP_PUSH, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_snprintf(), GNUNET_STATISTICS_set(), handle_inbound_channel(), Sub::hash, LOG, msub, Sub::num_observed_peers, Sub::observed_unique_peers, Sub::peer_map, Sub::pull_map, Sub::push_map, GNUNET_TIME_Relative::rel_value_us, Sub::round_interval, RPS_sampler_init(), Sub::sampler, Sub::sampler_size_est_min, Sub::sampler_size_est_need, stats, Sub::valid_peers, Sub::view, View_create(), and Sub::view_size_est_min.
Referenced by handle_client_start_sub(), and run().
|
static |
Destroy Sub.
sub | Sub to destroy |
Definition at line 3058 of file gnunet-service-rps.c.
References Sub::cadet_port, CustomPeerMap_destroy(), Sub::do_round_task, GNUNET_assert, GNUNET_CADET_close_port(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_free, GNUNET_SCHEDULER_cancel(), Sub::observed_unique_peers, peers_terminate(), Sub::pull_map, Sub::push_map, RPS_sampler_destroy(), Sub::sampler, Sub::view, and View_destroy().
Referenced by destroy_cli_ctx(), handle_client_start_sub(), handle_client_stop_sub(), and shutdown_task().
void core_init | ( | void * | cls, |
const struct GNUNET_PeerIdentity * | my_identity | ||
) |
Callback on initialisation of Core.
cls | - unused |
my_identity | - unused |
Definition at line 3128 of file gnunet-service-rps.c.
References GNUNET_MQ_MessageHandler::cls, GNUNET_CONTAINER_multipeermap_create(), GNUNET_NO, map_single_hop, and my_identity.
Referenced by run().
void * core_connects | ( | void * | cls, |
const struct GNUNET_PeerIdentity * | peer, | ||
struct GNUNET_MQ_Handle * | mq | ||
) |
Callback for core.
Method called whenever a given peer connects.
cls | closure - unused |
peer | peer identity this notification is about |
Definition at line 3147 of file gnunet-service-rps.c.
References GNUNET_MQ_MessageHandler::cls, GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_put(), GNUNET_YES, map_single_hop, and mq.
Referenced by run().
void core_disconnects | ( | void * | cls, |
const struct GNUNET_PeerIdentity * | peer, | ||
void * | peer_cls | ||
) |
Callback for core.
Method called whenever a peer disconnects.
cls | closure - unused |
peer | peer identity this notification is about |
peer_cls | closure given in core_connects - unused |
Definition at line 3172 of file gnunet-service-rps.c.
References GNUNET_MQ_MessageHandler::cls, GNUNET_CONTAINER_multipeermap_remove_all(), and map_single_hop.
Referenced by run().
|
static |
Destroy the context for a (connected) client.
cli_ctx | Context to destroy |
Definition at line 3194 of file gnunet-service-rps.c.
References cli_ctx_head, cli_ctx_tail, destroy_sub(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, and ClientContext::sub.
Referenced by client_disconnect_cb(), handle_client_view_cancel(), and shutdown_task().
|
static |
Update sizes in sampler and view on estimate update from nse service.
sub | Sub |
logestimate | the log(Base 2) value of the current network size estimate |
std_dev | standard deviation for the estimate |
Definition at line 3217 of file gnunet-service-rps.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_NSE_log_estimate_to_n, GNUNET_STATISTICS_set(), LOG, msub, resize_wrapper(), RPS_sampler_get_size(), Sub::sampler, Sub::sampler_size_est_need, stats, Sub::view, View_change_len(), Sub::view_size_est_min, and Sub::view_size_est_need.
Referenced by nse_callback().
|
static |
Function called by NSE.
Updates sizes of sampler list and view and adapt those lists accordingly.
implements GNUNET_NSE_Callback
cls | Closure - unused |
timestamp | time when the estimate was received from the server (or created by the server) |
logestimate | the log(Base 2) value of the current network size estimate |
std_dev | standard deviation for the estimate |
Definition at line 3272 of file gnunet-service-rps.c.
References adapt_sizes(), cli_ctx_head, GNUNET_MQ_MessageHandler::cls, msub, ClientContext::next, ClientContext::sub, and timestamp().
Referenced by run().
|
static |
This function is called, when the client seeds peers.
It verifies that msg is well-formed.
cls | the closure (ClientContext) |
msg | the message |
Definition at line 3303 of file gnunet-service-rps.c.
References ClientContext::client, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_OK, GNUNET_SERVICE_client_drop(), GNUNET_SYSERR, LOG, msg, num_peers, and GNUNET_MessageHeader::size.
|
static |
Handle seed from the client.
cls | closure |
msg | the actual message |
Definition at line 3332 of file gnunet-service-rps.c.
References ClientContext::client, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_SERVICE_client_continue(), got_peer(), LOG, msg, msub, num_peers, peers, print_peer_list(), and ClientContext::sub.
|
static |
Handle RPS request from the client.
cls | Client context |
msg | Message containing the number of updates the client wants to receive |
Definition at line 3371 of file gnunet-service-rps.c.
References ClientContext::client, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SERVICE_client_continue(), LOG, msg, send_view(), and ClientContext::view_updates_left.
|
static |
Handle the cancellation of the view updates.
cls | The client context |
msg | Unused |
Definition at line 3397 of file gnunet-service-rps.c.
References ClientContext::client, destroy_cli_ctx(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SERVICE_client_continue(), GNUNET_YES, LOG, msg, ClientContext::stream_update, and ClientContext::view_updates_left.
|
static |
Handle RPS request for biased stream from the client.
cls | Client context |
msg | unused |
Definition at line 3424 of file gnunet-service-rps.c.
References ClientContext::client, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SERVICE_client_continue(), GNUNET_YES, LOG, msg, and ClientContext::stream_update.
|
static |
Handles the cancellation of the stream of biased peer ids.
cls | The client context |
msg | unused |
Definition at line 3448 of file gnunet-service-rps.c.
References ClientContext::client, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_SERVICE_client_continue(), LOG, msg, and ClientContext::stream_update.
|
static |
Create and start a Sub.
cls | Closure - unused |
msg | Message containing the necessary information |
Definition at line 3471 of file gnunet-service-rps.c.
References ClientContext::client, destroy_sub(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_SERVICE_client_continue(), GNUNET_TIME_relative_ntoh(), Sub::hash, LOG, msg, msub, new_sub(), Sub::sampler_size_est_min, and ClientContext::sub.
|
static |
Destroy the Sub.
cls | Closure - unused |
msg | Message containing the hash that identifies the Sub |
Definition at line 3501 of file gnunet-service-rps.c.
References ClientContext::client, destroy_sub(), GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_SERVICE_client_continue(), Sub::hash, LOG, msg, and ClientContext::sub.
|
static |
Compute a random delay.
A uniformly distributed value between mean + spread and mean - spread.
For example for mean 4 min and spread 2 the minimum is (4 min - (1/2 * 4 min)) It would return a random value between 2 and 6 min.
mean | the mean time until the next round |
spread | the inverse amount of deviation from the mean |
Compute random value between (0 and 1) * round_interval via multiplying round_interval with a 'fraction' (0 to value)/value
Definition at line 3870 of file gnunet-service-rps.c.
References GNUNET_assert, GNUNET_break, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_WARNING, GNUNET_TIME_relative_add(), GNUNET_TIME_relative_divide(), GNUNET_TIME_relative_saturating_multiply(), GNUNET_TIME_UNIT_FOREVER_REL, LOG, and ret.
Referenced by do_round().
|
static |
Send single pull request.
peer_ctx | Context to the peer to send request to |
Definition at line 3916 of file gnunet-service-rps.c.
References check_peer_flag(), GNUNET_assert, GNUNET_CONTAINER_multipeermap_contains(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST, GNUNET_MQ_msg_header, GNUNET_NO, GNUNET_STATISTICS_update(), LOG, map_single_hop, Sub::num_rounds, PeerContext::peer_id, Sub::peer_map, Peers_PULL_REPLY_PENDING, PeerContext::round_pull_req, send_message(), SET_PEER_FLAG, stats, and PeerContext::sub.
Referenced by do_round().
|
static |
Send single push.
peer_ctx | Context of peer to send push to |
Definition at line 3960 of file gnunet-service-rps.c.
References GNUNET_CONTAINER_multipeermap_contains(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_MESSAGE_TYPE_RPS_PP_PUSH, GNUNET_MQ_msg_header, GNUNET_NO, GNUNET_STATISTICS_update(), LOG, map_single_hop, PeerContext::peer_id, send_message(), stats, and PeerContext::sub.
Referenced by do_round().
void init_peer_cb | ( | void * | cls, |
const struct GNUNET_PeerIdentity * | peer, | ||
int | tunnel, | ||
unsigned int | n_paths, | ||
unsigned int | best_path | ||
) |
This is called from GNUNET_CADET_get_peers().
It is called on every peer(ID) that cadet somehow has contact with. We use those to initialise the sampler.
implements GNUNET_CADET_PeersCB
cls | Closure - Sub |
peer | Peer, or NULL on "EOF". |
tunnel | Do we have a tunnel towards this peer? |
n_paths | Number of known paths towards this peer. |
best_path | How long is the best path? (0 = unknown, 1 = ourselves, 2 = neighbor) |
Definition at line 4639 of file gnunet-service-rps.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), got_peer(), and LOG.
|
static |
Iterator function over stored, valid peers.
We initialise the sampler with those.
cls | Closure - Sub |
peer | the peer id |
Definition at line 4674 of file gnunet-service-rps.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_YES, got_peer(), and LOG.
Referenced by run().
void process_peerinfo_peers | ( | void * | cls, |
const struct GNUNET_PEERSTORE_Record * | record, | ||
const char * | emsg | ||
) |
Iterator over peers from peerinfo.
cls | Closure - Sub |
peer | id of the peer, NULL for last call |
hello | hello message for the peer (can be NULL) |
err_msg | error message |
Definition at line 4699 of file gnunet-service-rps.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_PEERSTORE_monitor_next(), got_peer(), LOG, peerstore_notify, and record().
Referenced by run().
|
static |
Task run during shutdown.
cls | Closure - unused |
Definition at line 4720 of file gnunet-service-rps.c.
References cadet_handle, cli_ctx_head, close_all_files(), core_handle, destroy_cli_ctx(), destroy_sub(), GNUNET_array_grow, GNUNET_CADET_disconnect(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CORE_disconnect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_NO, GNUNET_NSE_disconnect(), GNUNET_PEERSTORE_disconnect(), GNUNET_PEERSTORE_monitor_stop(), GNUNET_STATISTICS_destroy(), LOG, map_single_hop, msub, nse, peerstore, peerstore_notify, and stats.
Referenced by run().
|
static |
Handle client connecting to the service.
cls | unused |
client | the new client |
mq | the message queue of client |
Definition at line 4795 of file gnunet-service-rps.c.
References cli_ctx_head, cli_ctx_tail, ClientContext::client, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_NO, LOG, mq, ClientContext::mq, ClientContext::stream_update, and ClientContext::view_updates_left.
|
static |
Callback called when a client disconnected from the service.
cls | closure for the service |
client | the client that disconnected |
internal_cls | should be equal to c |
Definition at line 4827 of file gnunet-service-rps.c.
References cli_ctx_head, ClientContext::client, destroy_cli_ctx(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, and LOG.
|
static |
Definition at line 4850 of file gnunet-service-rps.c.
References GNUNET_ERROR_TYPE_WARNING, and GNUNET_log.
Referenced by run().
|
static |
Definition at line 4858 of file gnunet-service-rps.c.
References GNUNET_ERROR_TYPE_WARNING, and GNUNET_log.
Referenced by run().
|
static |
Handle random peer sampling clients.
cls | closure |
c | configuration to use |
service | the initialized service |
Definition at line 4873 of file gnunet-service-rps.c.
References alpha, beta, cadet_handle, cfg, core_connects(), core_disconnects(), core_handle, core_init(), error_cb(), get_valid_peers(), GNUNET_APPLICATION_PORT_RPS, GNUNET_assert, GNUNET_CADET_connect(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CORE_connect(), GNUNET_CRYPTO_get_peer_identity(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_error_type_to_string(), GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_log, GNUNET_log_config_missing(), GNUNET_log_setup(), GNUNET_NSE_connect(), GNUNET_OK, GNUNET_PEERSTORE_connect(), GNUNET_PEERSTORE_HELLO_KEY, GNUNET_PEERSTORE_monitor_start(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_create(), GNUNET_YES, LOG, msub, new_sub(), nse, nse_callback(), own_identity, peerstore, peerstore_notify, process_peerinfo_peers(), restore_valid_peers(), service, shutdown_task(), stats, sync_cb(), Sub::valid_peers, and valid_peers_iterator().
Define "main" method using service macro.
|
static |
Our configuration.
Definition at line 457 of file gnunet-service-rps.c.
struct GNUNET_STATISTICS_Handle* stats |
Handle to the statistics service.
Definition at line 462 of file gnunet-service-rps.c.
Referenced by adapt_sizes(), add_valid_peer(), check_peer_online(), check_peer_pull_reply(), create_peer_ctx(), destroy_peer(), do_round(), got_peer(), handle_peer_check(), handle_peer_pull_reply(), handle_peer_pull_request(), handle_peer_push(), insert_in_sampler(), insert_in_view(), mq_notify_sent_cb(), new_sub(), run(), send_pull_reply(), send_pull_request(), send_push(), and shutdown_task().
struct GNUNET_CADET_Handle* cadet_handle |
Handler to CADET.
Cadet channel for creating outbound channels.
Definition at line 467 of file gnunet-service-rps.c.
Referenced by get_channel(), GSF_cadet_start_server(), GSF_cadet_stop_server(), new_sub(), run(), and shutdown_task().
struct GNUNET_CORE_Handle* core_handle |
Handle to CORE.
Definition at line 472 of file gnunet-service-rps.c.
Referenced by run(), and shutdown_task().
struct GNUNET_CONTAINER_MultiPeerMap* map_single_hop |
PeerMap to keep track of connected peers.
Definition at line 477 of file gnunet-service-rps.c.
Referenced by core_connects(), core_disconnects(), core_init(), handle_peer_pull_reply(), handle_peer_pull_request(), handle_peer_push(), mq_notify_sent_cb(), send_pull_request(), send_push(), and shutdown_task().
|
static |
|
static |
Percentage of total peer number in the view to send random PUSHes to.
Definition at line 488 of file gnunet-service-rps.c.
Referenced by checkvec(), do_round(), GNUNET_CRYPTO_cs_blinding_secrets_derive(), output_vectors(), and run().
|
static |
Percentage of total peer number in the view to send random PULLs to.
Definition at line 494 of file gnunet-service-rps.c.
Referenced by checkvec(), do_round(), GNUNET_CRYPTO_cs_blinding_secrets_derive(), insert_decrypt_element(), output_vectors(), and run().
|
static |
Handler to NSE.
Definition at line 499 of file gnunet-service-rps.c.
Referenced by run(), and shutdown_task().
|
static |
Handle to the PEERSTORE service.
Definition at line 504 of file gnunet-service-rps.c.
Referenced by run(), and shutdown_task().
|
static |
Our peerstore notification context.
We use notification to instantly learn about new peers as they are discovered.
Definition at line 510 of file gnunet-service-rps.c.
Referenced by process_peerinfo_peers(), run(), and shutdown_task().
|
static |
Main Sub.
This is run in any case by all peers and connects to all peers without specifying a shared value.
Definition at line 585 of file gnunet-service-rps.c.
Referenced by adapt_sizes(), add_valid_peer(), check_peer_online(), check_peer_pull_reply(), clients_notify_stream_peer(), create_peer_ctx(), destroy_peer(), do_round(), got_peer(), handle_client_seed(), handle_client_start_sub(), handle_peer_check(), handle_peer_pull_reply(), handle_peer_pull_request(), handle_peer_push(), insert_in_sampler(), insert_in_view(), mq_notify_sent_cb(), new_sub(), nse_callback(), run(), send_pull_reply(), send_view(), and shutdown_task().
|
static |
Maximum number of valid peers to keep.
TODO read from config
Definition at line 591 of file gnunet-service-rps.c.
Referenced by add_valid_peer().
struct ClientContext* cli_ctx_head |
DLL with all clients currently connected to us.
Definition at line 2129 of file gnunet-service-rps.c.
Referenced by client_connect_cb(), client_disconnect_cb(), clients_notify_stream_peer(), clients_notify_view_update(), destroy_cli_ctx(), nse_callback(), and shutdown_task().
struct ClientContext* cli_ctx_tail |
Definition at line 2130 of file gnunet-service-rps.c.
Referenced by client_connect_cb(), and destroy_cli_ctx().