[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: -migrate code to new block API
From: |
gnunet |
Subject: |
[gnunet] branch master updated: -migrate code to new block API |
Date: |
Wed, 29 Dec 2021 20:47:22 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 9e0d7d411 -migrate code to new block API
9e0d7d411 is described below
commit 9e0d7d411363999bca89f7e7b4e2896b8f6ec931
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Dec 29 20:47:17 2021 +0100
-migrate code to new block API
---
src/dht/gnunet-service-dht_neighbours.c | 39 +++++++------
src/fs/gnunet-service-fs.c | 12 ++--
src/fs/gnunet-service-fs.h | 2 +-
src/fs/gnunet-service-fs_cp.c | 26 ++++-----
src/fs/gnunet-service-fs_pr.c | 99 ++++++++++++++++-----------------
src/fs/gnunet-service-fs_pr.h | 28 +++++-----
src/fs/test_plugin_block_fs.c | 45 +++++++--------
7 files changed, 122 insertions(+), 129 deletions(-)
diff --git a/src/dht/gnunet-service-dht_neighbours.c
b/src/dht/gnunet-service-dht_neighbours.c
index 75bdaed53..d48d2a5df 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -1859,18 +1859,17 @@ handle_find_peer (const struct GNUNET_PeerIdentity
*sender,
/* first, check about our own HELLO */
if (NULL != GDS_my_hello)
{
- hello_size = GNUNET_HELLO_size ((const struct
- GNUNET_HELLO_Message *) GDS_my_hello);
+ hello_size = GNUNET_HELLO_size (
+ (const struct GNUNET_HELLO_Message *) GDS_my_hello);
GNUNET_break (hello_size >= sizeof(struct GNUNET_MessageHeader));
- if (GNUNET_BLOCK_EVALUATION_OK_MORE ==
- GNUNET_BLOCK_evaluate (GDS_block_context,
- GNUNET_BLOCK_TYPE_DHT_HELLO,
- bg,
- GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO,
- &my_identity_hash,
- NULL, 0,
- GDS_my_hello,
- hello_size))
+ if (GNUNET_BLOCK_REPLY_OK_MORE ==
+ GNUNET_BLOCK_check_reply (GDS_block_context,
+ GNUNET_BLOCK_TYPE_DHT_HELLO,
+ bg,
+ &my_identity_hash,
+ NULL, 0,
+ GDS_my_hello,
+ hello_size))
{
GDS_NEIGHBOURS_handle_reply (sender,
GNUNET_BLOCK_TYPE_DHT_HELLO,
@@ -1933,16 +1932,16 @@ handle_find_peer (const struct GNUNET_PeerIdentity
*sender,
peer = bucket->head;
hello = GDS_HELLO_get (peer->id);
}
+ /* FIXME: this logic is strange. extra ';', maybe, but then why a while-loop
at all? */
while ((NULL == hello) ||
- (GNUNET_BLOCK_EVALUATION_OK_MORE !=
- GNUNET_BLOCK_evaluate (GDS_block_context,
- GNUNET_BLOCK_TYPE_DHT_HELLO,
- bg,
- GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO,
- &peer->phash,
- NULL, 0,
- hello,
- (hello_size = GNUNET_HELLO_size (hello)))));
+ (GNUNET_BLOCK_REPLY_OK_MORE !=
+ GNUNET_BLOCK_check_reply (GDS_block_context,
+ GNUNET_BLOCK_TYPE_DHT_HELLO,
+ bg,
+ &peer->phash,
+ NULL, 0,
+ hello,
+ (hello_size = GNUNET_HELLO_size
(hello)))));
GDS_NEIGHBOURS_handle_reply (sender,
GNUNET_BLOCK_TYPE_DHT_HELLO,
GNUNET_TIME_relative_to_absolute
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index e90ba4c8b..8c6c39885 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -395,7 +395,7 @@ client_request_destroy (void *cls)
*/
static void
client_response_handler (void *cls,
- enum GNUNET_BLOCK_EvaluationResult eval,
+ enum GNUNET_BLOCK_ReplyEvaluationResult eval,
struct GSF_PendingRequest *pr,
uint32_t reply_anonymity_level,
struct GNUNET_TIME_Absolute expiration,
@@ -447,7 +447,7 @@ client_response_handler (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Queued reply to query `%s' for local client\n",
GNUNET_h2s (&prd->query));
- if (GNUNET_BLOCK_EVALUATION_OK_LAST != eval)
+ if (GNUNET_BLOCK_REPLY_OK_LAST != eval)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Evaluation %d - keeping query alive\n",
@@ -668,9 +668,9 @@ consider_request_for_forwarding (void *cls,
void
GSF_consider_forwarding (void *cls,
struct GSF_PendingRequest *pr,
- enum GNUNET_BLOCK_EvaluationResult result)
+ enum GNUNET_BLOCK_ReplyEvaluationResult result)
{
- if (GNUNET_BLOCK_EVALUATION_OK_LAST == result)
+ if (GNUNET_BLOCK_REPLY_OK_LAST == result)
return; /* we're done... */
if (GNUNET_YES !=
GSF_pending_request_test_active_ (pr))
@@ -737,13 +737,13 @@ check_p2p_get (void *cls,
static void
start_p2p_processing (void *cls,
struct GSF_PendingRequest *pr,
- enum GNUNET_BLOCK_EvaluationResult result)
+ enum GNUNET_BLOCK_ReplyEvaluationResult result)
{
struct GSF_LocalClient *lc = cls;
struct GSF_PendingRequestData *prd;
GNUNET_SERVICE_client_continue (lc->client);
- if (GNUNET_BLOCK_EVALUATION_OK_LAST == result)
+ if (GNUNET_BLOCK_REPLY_OK_LAST == result)
return; /* we're done, 'pr' was already destroyed... */
prd = GSF_pending_request_get_data_ (pr);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/fs/gnunet-service-fs.h b/src/fs/gnunet-service-fs.h
index 9c87115ed..a6b73db09 100644
--- a/src/fs/gnunet-service-fs.h
+++ b/src/fs/gnunet-service-fs.h
@@ -280,7 +280,7 @@ extern unsigned int GSF_datastore_queue_size;
void
GSF_consider_forwarding (void *cls,
struct GSF_PendingRequest *pr,
- enum GNUNET_BLOCK_EvaluationResult result);
+ enum GNUNET_BLOCK_ReplyEvaluationResult result);
/**
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index c174ad611..5476aa2be 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -836,7 +836,7 @@ get_randomized_delay ()
*/
static void
handle_p2p_reply (void *cls,
- enum GNUNET_BLOCK_EvaluationResult eval,
+ enum GNUNET_BLOCK_ReplyEvaluationResult eval,
struct GSF_PendingRequest *pr,
uint32_t reply_anonymity_level,
struct GNUNET_TIME_Absolute expiration,
@@ -862,11 +862,11 @@ handle_p2p_reply (void *cls,
return;
}
GNUNET_break (GNUNET_BLOCK_TYPE_ANY != type);
- if ((prd->type != type) && (GNUNET_BLOCK_TYPE_ANY != prd->type))
+ if ( (prd->type != type) &&
+ (GNUNET_BLOCK_TYPE_ANY != prd->type) )
{
GNUNET_STATISTICS_update (GSF_stats,
- gettext_noop
- ("# replies dropped due to type mismatch"),
+ "# replies dropped due to type mismatch",
1, GNUNET_NO);
return;
}
@@ -874,22 +874,22 @@ handle_p2p_reply (void *cls,
"Transmitting result for query `%s' to peer\n",
GNUNET_h2s (&prd->query));
GNUNET_STATISTICS_update (GSF_stats,
- gettext_noop ("# replies received for other
peers"),
- 1, GNUNET_NO);
+ "# replies received for other peers",
+ 1,
+ GNUNET_NO);
msize = sizeof(struct PutMessage) + data_len;
if (msize >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
}
- if ((UINT32_MAX != reply_anonymity_level) && (reply_anonymity_level > 1))
+ if ( (UINT32_MAX != reply_anonymity_level) &&
+ (reply_anonymity_level > 1) )
{
if (reply_anonymity_level - 1 > GSF_cover_content_count)
{
GNUNET_STATISTICS_update (GSF_stats,
- gettext_noop
- (
- "# replies dropped due to insufficient cover
traffic"),
+ "# replies dropped due to insufficient cover
traffic",
1, GNUNET_NO);
return;
}
@@ -930,14 +930,12 @@ handle_p2p_reply (void *cls,
UINT32_MAX,
env);
}
- if (GNUNET_BLOCK_EVALUATION_OK_LAST != eval)
+ if (GNUNET_BLOCK_REPLY_OK_LAST != eval)
return;
if (NULL == peerreq->kill_task)
{
GNUNET_STATISTICS_update (GSF_stats,
- gettext_noop
- (
- "# P2P searches destroyed due to ultimate
reply"),
+ "# P2P searches destroyed due to ultimate reply",
1,
GNUNET_NO);
peerreq->kill_task =
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c
index a5db4b6b7..c3fe5ff58 100644
--- a/src/fs/gnunet-service-fs_pr.c
+++ b/src/fs/gnunet-service-fs_pr.c
@@ -135,7 +135,7 @@ struct GSF_PendingRequest
/**
* Last result from the local datastore lookup evaluation.
*/
- enum GNUNET_BLOCK_EvaluationResult local_result;
+ enum GNUNET_BLOCK_ReplyEvaluationResult local_result;
/**
* Identity of the peer that we should use for the 'sender'
@@ -619,7 +619,9 @@ clean_request (void *cls, const struct GNUNET_HashCode
*key, void *value)
if (NULL != (cont = pr->llc_cont))
{
pr->llc_cont = NULL;
- cont (pr->llc_cont_cls, pr, pr->local_result);
+ cont (pr->llc_cont_cls,
+ pr,
+ pr->local_result);
}
GSF_plan_notify_request_done_ (pr);
GNUNET_free (pr->replies_seen);
@@ -689,7 +691,9 @@ GSF_pending_request_cancel_ (struct GSF_PendingRequest *pr,
int full_cleanup)
if (NULL != (cont = pr->llc_cont))
{
pr->llc_cont = NULL;
- cont (pr->llc_cont_cls, pr, pr->local_result);
+ cont (pr->llc_cont_cls,
+ pr,
+ pr->local_result);
}
GSF_plan_notify_request_done_ (pr);
if (NULL != pr->qe)
@@ -778,7 +782,7 @@ struct ProcessReplyClosure
/**
* Evaluation result (returned).
*/
- enum GNUNET_BLOCK_EvaluationResult eval;
+ enum GNUNET_BLOCK_ReplyEvaluationResult eval;
/**
* Did we find a matching request?
@@ -814,8 +818,10 @@ update_request_performance_data (struct
ProcessReplyClosure *prq,
* @param value value in the hash map (info about the query)
* @return #GNUNET_YES (we should continue to iterate)
*/
-static int
-process_reply (void *cls, const struct GNUNET_HashCode *key, void *value)
+static enum GNUNET_GenericReturnValue
+process_reply (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct ProcessReplyClosure *prq = cls;
struct GSF_PendingRequest *pr = value;
@@ -832,22 +838,20 @@ process_reply (void *cls, const struct GNUNET_HashCode
*key, void *value)
gettext_noop ("# replies received and matched"),
1,
GNUNET_NO);
- prq->eval = GNUNET_BLOCK_evaluate (GSF_block_ctx,
- prq->type,
- pr->bg,
- prq->eo,
- key,
- NULL,
- 0,
- prq->data,
- prq->size);
+ prq->eval = GNUNET_BLOCK_check_reply (GSF_block_ctx,
+ prq->type,
+ pr->bg,
+ key,
+ NULL, 0,
+ prq->data,
+ prq->size);
switch (prq->eval)
{
- case GNUNET_BLOCK_EVALUATION_OK_MORE:
+ case GNUNET_BLOCK_REPLY_OK_MORE:
update_request_performance_data (prq, pr);
break;
- case GNUNET_BLOCK_EVALUATION_OK_LAST:
+ case GNUNET_BLOCK_REPLY_OK_LAST:
/* short cut: stop processing early, no BF-update, etc. */
update_request_performance_data (prq, pr);
GNUNET_LOAD_update (GSF_rt_entry_lifetime,
@@ -859,8 +863,7 @@ process_reply (void *cls, const struct GNUNET_HashCode
*key, void *value)
.pr_head,
prq->sender,
&last_transmission))
- last_transmission.abs_value_us =
- GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
+ last_transmission = GNUNET_TIME_UNIT_FOREVER_ABS;
/* pass on to other peers / local clients */
pr->rh (pr->rh_cls,
prq->eval,
@@ -872,46 +875,38 @@ process_reply (void *cls, const struct GNUNET_HashCode
*key, void *value)
prq->data,
prq->size);
return GNUNET_YES;
-
- case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
+ case GNUNET_BLOCK_REPLY_OK_DUPLICATE:
#if INSANE_STATISTICS
GNUNET_STATISTICS_update (GSF_stats,
- gettext_noop (
- "# duplicate replies discarded (bloomfilter)"),
+ "# duplicate replies discarded (bloomfilter)",
1,
GNUNET_NO);
#endif
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Duplicate response, discarding.\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Duplicate response, discarding.\n");
return GNUNET_YES; /* duplicate */
- case GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT:
+ case GNUNET_BLOCK_REPLY_IRRELEVANT:
GNUNET_STATISTICS_update (GSF_stats,
- gettext_noop ("# irrelevant replies discarded"),
+ "# irrelevant replies discarded",
1,
GNUNET_NO);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Irrelevant response, ignoring.\n");
- return GNUNET_YES;
-
- case GNUNET_BLOCK_EVALUATION_RESULT_INVALID:
- return GNUNET_YES; /* wrong namespace */
-
- case GNUNET_BLOCK_EVALUATION_REQUEST_VALID:
- GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Irrelevant response, ignoring.\n");
return GNUNET_YES;
-
- case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID:
- GNUNET_break (0);
+ case GNUNET_BLOCK_REPLY_INVALID:
return GNUNET_YES;
-
- case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ ("Unsupported block type %u\n"),
- prq->type);
+ case GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED:
+ GNUNET_break (0); /* bad installation? */
return GNUNET_NO;
}
/* update bloomfilter */
- GNUNET_CRYPTO_hash (prq->data, prq->size, &chash);
- GSF_pending_request_update_ (pr, &chash, 1);
+ GNUNET_CRYPTO_hash (prq->data,
+ prq->size,
+ &chash);
+ GSF_pending_request_update_ (pr,
+ &chash,
+ 1);
if (NULL == prq->sender)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -936,7 +931,7 @@ process_reply (void *cls, const struct GNUNET_HashCode
*key, void *value)
.pr_head,
prq->sender,
&last_transmission))
- last_transmission.abs_value_us = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
+ last_transmission = GNUNET_TIME_UNIT_FOREVER_ABS;
pr->rh (pr->rh_cls,
prq->eval,
pr,
@@ -1363,12 +1358,12 @@ call_continuation (struct GSF_PendingRequest *pr)
pr->llc_cont = NULL;
if (0 != (GSF_PRO_LOCAL_ONLY & pr->public_data.options))
{
- if (GNUNET_BLOCK_EVALUATION_OK_LAST != pr->local_result)
+ if (GNUNET_BLOCK_REPLY_OK_LAST != pr->local_result)
{
/* Signal that we are done and that there won't be any
additional results to allow client to clean up state. */
pr->rh (pr->rh_cls,
- GNUNET_BLOCK_EVALUATION_OK_LAST,
+ GNUNET_BLOCK_REPLY_OK_LAST,
pr,
UINT32_MAX,
GNUNET_TIME_UNIT_ZERO_ABS,
@@ -1380,11 +1375,15 @@ call_continuation (struct GSF_PendingRequest *pr)
/* Finally, call our continuation to signal that we are
done with local processing of this request; i.e. to
start reading again from the client. */
- cont (pr->llc_cont_cls, NULL, GNUNET_BLOCK_EVALUATION_OK_LAST);
+ cont (pr->llc_cont_cls,
+ NULL,
+ GNUNET_BLOCK_REPLY_OK_LAST);
return;
}
- cont (pr->llc_cont_cls, pr, pr->local_result);
+ cont (pr->llc_cont_cls,
+ pr,
+ pr->local_result);
}
@@ -1635,7 +1634,7 @@ called_from_on_demand:
prq.eo = GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO;
process_reply (&prq, key, pr);
pr->local_result = prq.eval;
- if (GNUNET_BLOCK_EVALUATION_OK_LAST == prq.eval)
+ if (GNUNET_BLOCK_REPLY_OK_LAST == prq.eval)
{
GNUNET_STATISTICS_update (
GSF_stats,
diff --git a/src/fs/gnunet-service-fs_pr.h b/src/fs/gnunet-service-fs_pr.h
index 58fdd334e..a10fb9b4c 100644
--- a/src/fs/gnunet-service-fs_pr.h
+++ b/src/fs/gnunet-service-fs_pr.h
@@ -184,16 +184,17 @@ struct GSF_PendingRequestData
* @param data_len number of bytes in @a data
*/
typedef void
-(*GSF_PendingRequestReplyHandler) (void *cls,
- enum GNUNET_BLOCK_EvaluationResult eval,
- struct GSF_PendingRequest *pr,
- uint32_t reply_anonymity_level,
- struct GNUNET_TIME_Absolute expiration,
- struct GNUNET_TIME_Absolute
- last_transmission,
- enum GNUNET_BLOCK_Type type,
- const void *data,
- size_t data_len);
+(*GSF_PendingRequestReplyHandler) (
+ void *cls,
+ enum GNUNET_BLOCK_ReplyEvaluationResult eval,
+ struct GSF_PendingRequest *pr,
+ uint32_t reply_anonymity_level,
+ struct GNUNET_TIME_Absolute expiration,
+ struct GNUNET_TIME_Absolute
+ last_transmission,
+ enum GNUNET_BLOCK_Type type,
+ const void *data,
+ size_t data_len);
/**
@@ -374,9 +375,10 @@ GSF_cadet_lookup_ (struct GSF_PendingRequest *pr);
* @param result final datastore lookup result
*/
typedef void
-(*GSF_LocalLookupContinuation) (void *cls,
- struct GSF_PendingRequest *pr,
- enum GNUNET_BLOCK_EvaluationResult result);
+(*GSF_LocalLookupContinuation) (
+ void *cls,
+ struct GSF_PendingRequest *pr,
+ enum GNUNET_BLOCK_ReplyEvaluationResult result);
/**
diff --git a/src/fs/test_plugin_block_fs.c b/src/fs/test_plugin_block_fs.c
index 4f71c5d74..727cc37c2 100644
--- a/src/fs/test_plugin_block_fs.c
+++ b/src/fs/test_plugin_block_fs.c
@@ -34,36 +34,31 @@ test_fs (struct GNUNET_BLOCK_Context *ctx)
memset (block, 1, sizeof(block));
if (GNUNET_OK !=
- GNUNET_BLOCK_get_key (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, block,
- sizeof(block), &key))
+ GNUNET_BLOCK_get_key (ctx,
+ GNUNET_BLOCK_TYPE_FS_DBLOCK,
+ block,
+ sizeof(block),
+ &key))
return 1;
- if (GNUNET_BLOCK_EVALUATION_OK_LAST !=
- GNUNET_BLOCK_evaluate (ctx,
- GNUNET_BLOCK_TYPE_FS_DBLOCK,
- NULL,
- GNUNET_BLOCK_EO_NONE,
- &key,
- NULL, 0,
- block, sizeof(block)))
+ if (GNUNET_OK !=
+ GNUNET_BLOCK_check_block (ctx,
+ GNUNET_BLOCK_TYPE_FS_DBLOCK,
+ &key,
+ block,
+ sizeof(block)))
return 2;
- if (GNUNET_BLOCK_EVALUATION_REQUEST_VALID !=
- GNUNET_BLOCK_evaluate (ctx,
- GNUNET_BLOCK_TYPE_FS_DBLOCK,
- NULL,
- GNUNET_BLOCK_EO_NONE,
- &key,
- NULL, 0,
- NULL, 0))
+ if (GNUNET_OK !=
+ GNUNET_BLOCK_check_query (ctx,
+ GNUNET_BLOCK_TYPE_FS_DBLOCK,
+ &key,
+ NULL, 0))
return 4;
GNUNET_log_skip (1, GNUNET_NO);
if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID !=
- GNUNET_BLOCK_evaluate (ctx,
- GNUNET_BLOCK_TYPE_FS_DBLOCK,
- NULL,
- GNUNET_BLOCK_EO_NONE,
- &key,
- "bogus", 5,
- NULL, 0))
+ GNUNET_BLOCK_check_query (ctx,
+ GNUNET_BLOCK_TYPE_FS_DBLOCK,
+ &key,
+ "bogus", 5))
return 8;
GNUNET_log_skip (0, GNUNET_YES);
return 0;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: -migrate code to new block API,
gnunet <=