From 1c24355745a810d20b9fd7545631be6300d0b71c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 21 Apr 2019 14:54:04 +0200 Subject: define constant --- src/include/gnunet_peerstore_service.h | 30 +++++++++++++++------------- src/transport/gnunet-service-tng.c | 36 ++++++++++++++++++---------------- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/src/include/gnunet_peerstore_service.h b/src/include/gnunet_peerstore_service.h index d9acf0576..b20c1f3c7 100644 --- a/src/include/gnunet_peerstore_service.h +++ b/src/include/gnunet_peerstore_service.h @@ -36,9 +36,8 @@ #include "gnunet_util_lib.h" #ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ +extern "C" { +#if 0 /* keep Emacsens' auto-indent happy */ } #endif #endif @@ -54,6 +53,12 @@ extern "C" */ #define GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY "transport-peer-hello" +/** + * Key used to store sender's monotonic time from backchannel + * messages. + */ +#define GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME \ + "transport-backchannel-monotonic-time" /** * Options for storing values in PEERSTORE @@ -134,9 +139,7 @@ struct GNUNET_PEERSTORE_Record * @param cls closure * @param success #GNUNET_OK or #GNUNET_SYSERR */ -typedef void -(*GNUNET_PEERSTORE_Continuation)(void *cls, - int success); +typedef void (*GNUNET_PEERSTORE_Continuation) (void *cls, int success); /** @@ -146,10 +149,10 @@ typedef void * @param record peerstore record information * @param emsg error message, or NULL if no errors */ -typedef void -(*GNUNET_PEERSTORE_Processor) (void *cls, - const struct GNUNET_PEERSTORE_Record *record, - const char *emsg); +typedef void (*GNUNET_PEERSTORE_Processor) ( + void *cls, + const struct GNUNET_PEERSTORE_Record *record, + const char *emsg); /** @@ -170,8 +173,7 @@ GNUNET_PEERSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); * @param sync_first send any pending STORE requests before disconnecting */ void -GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, - int sync_first); +GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, int sync_first); /** @@ -271,7 +273,7 @@ void GNUNET_PEERSTORE_watch_cancel (struct GNUNET_PEERSTORE_WatchContext *wc); -#if 0 /* keep Emacsens' auto-indent happy */ +#if 0 /* keep Emacsens' auto-indent happy */ { #endif #ifdef __cplusplus @@ -280,4 +282,4 @@ GNUNET_PEERSTORE_watch_cancel (struct GNUNET_PEERSTORE_WatchContext *wc); #endif -/** @} */ /* end of group */ +/** @} */ /* end of group */ diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index 4dc3a137d..7683ed016 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c @@ -28,7 +28,7 @@ * - proper use/initialization of timestamps in messages exchanged * during DV learning * - persistence of monotonic time obtained from other peers - * in PEERSTORE (by message type) + * in PEERSTORE (by message type) -- done for backchannel, needed elsewhere? * - change transport-core API to provide proper flow control in both * directions, allow multiple messages per peer simultaneously (tag * confirmations with unique message ID), and replace quota-out with @@ -4874,16 +4874,17 @@ update_backtalker_monotime (struct Backtalker *b) b->task = NULL; } mtbe = GNUNET_TIME_absolute_hton (b->monotonic_time); - b->sc = GNUNET_PEERSTORE_store (peerstore, - "transport", - &b->pid, - "transport-backchannel-monotonic-time", - &mtbe, - sizeof (mtbe), - GNUNET_TIME_UNIT_FOREVER_ABS, - GNUNET_PEERSTORE_STOREOPTION_REPLACE, - &backtalker_monotime_store_cb, - b); + b->sc = + GNUNET_PEERSTORE_store (peerstore, + "transport", + &b->pid, + GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME, + &mtbe, + sizeof (mtbe), + GNUNET_TIME_UNIT_FOREVER_ABS, + GNUNET_PEERSTORE_STOREOPTION_REPLACE, + &backtalker_monotime_store_cb, + b); } @@ -5003,12 +5004,13 @@ handle_backchannel_encapsulation ( b->timeout = GNUNET_TIME_relative_to_absolute (BACKCHANNEL_INACTIVITY_TIMEOUT); b->task = GNUNET_SCHEDULER_add_at (b->timeout, &backtalker_timeout_cb, b); - b->get = GNUNET_PEERSTORE_iterate (peerstore, - "transport", - &b->pid, - "transport-backchannel-monotonic-time", - &backtalker_monotime_cb, - b); + b->get = + GNUNET_PEERSTORE_iterate (peerstore, + "transport", + &b->pid, + GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME, + &backtalker_monotime_cb, + b); } } -- cgit v1.2.3