Next: , Up: Implementing a block plugin   [Contents]


4.7.3.1 Validating requests and replies

The evaluate function should validate a reply or a request. It returns a GNUNET\_BLOCK\_EvaluationResult, which is an enumeration. All possible answers are in gnunet\_block\_lib.h. The function will be called with a reply\_block argument of NULL for requests. Note that depending on how evaluate is called, only some of the possible return values are valid. The specific meaning of the xquery argument is application-specific. Applications that do not use an extended query should check that the xquery\_size is zero. The block group is typically used to filter duplicate replies.

static enum GNUNET_BLOCK_EvaluationResult
block_plugin_SERVICE_evaluate (void *cls,
                              enum GNUNET_BLOCK_Type type,
                              struct GNUNET_BlockGroup *bg,
                              const GNUNET_HashCode *query,
                              const void *xquery,
                              size_t xquery_size,
                              const void *reply_block,
                              size_t reply_block_size)
{
  // Verify type, block and bg
}

Note that it is mandatory to detect duplicate replies in this function and return the respective status code. Duplicate detection is typically done using the Bloom filter block group provided by libgnunetblockgroup.so. Failure to do so may cause replies to circle in the network.