From ccc37ce1438490a519e33d97829277ba16221425 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Wed, 19 Dec 2012 13:02:42 +0000 Subject: [PATCH] -prevent looping of mesh messages in the DHT --- src/mesh/plugin_block_mesh.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/mesh/plugin_block_mesh.c b/src/mesh/plugin_block_mesh.c index a8ac085a0..b8a034da2 100644 --- a/src/mesh/plugin_block_mesh.c +++ b/src/mesh/plugin_block_mesh.c @@ -77,6 +77,22 @@ block_plugin_mesh_evaluate (void *cls, enum GNUNET_BLOCK_Type type, return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; if (sizeof (struct PBlock) != reply_block_size) return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; + if (NULL != bf) + { + GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash); + GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash); + if (NULL != *bf) + { + if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash)) + return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; + } + else + { + *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K); + } + GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash); + } + return GNUNET_BLOCK_EVALUATION_OK_LAST; -- 2.25.1