GNUnet  0.10.x
Functions
plugin_block_consensus.c File Reference

consensus block, either nested block or marker More...

#include "platform.h"
#include "consensus_protocol.h"
#include "gnunet_block_plugin.h"
#include "gnunet_block_group_lib.h"
Include dependency graph for plugin_block_consensus.c:

Go to the source code of this file.

Functions

static enum GNUNET_BLOCK_EvaluationResult block_plugin_consensus_evaluate (void *cls, struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, struct GNUNET_BLOCK_Group *group, enum GNUNET_BLOCK_EvaluationOptions eo, const struct GNUNET_HashCode *query, const void *xquery, size_t xquery_size, const void *reply_block, size_t reply_block_size)
 Function called to validate a reply or a request. More...
 
static int block_plugin_consensus_get_key (void *cls, enum GNUNET_BLOCK_Type type, const void *block, size_t block_size, struct GNUNET_HashCode *key)
 Function called to obtain the key for a block. More...
 
void * libgnunet_plugin_block_consensus_init (void *cls)
 Entry point for the plugin. More...
 
void * libgnunet_plugin_block_consensus_done (void *cls)
 Exit point from the plugin. More...
 

Detailed Description

consensus block, either nested block or marker

Author
Christian Grothoff

Definition in file plugin_block_consensus.c.

Function Documentation

◆ block_plugin_consensus_evaluate()

static enum GNUNET_BLOCK_EvaluationResult block_plugin_consensus_evaluate ( void *  cls,
struct GNUNET_BLOCK_Context ctx,
enum GNUNET_BLOCK_Type  type,
struct GNUNET_BLOCK_Group group,
enum GNUNET_BLOCK_EvaluationOptions  eo,
const struct GNUNET_HashCode query,
const void *  xquery,
size_t  xquery_size,
const void *  reply_block,
size_t  reply_block_size 
)
static

Function called to validate a reply or a request.

For request evaluation, simply pass "NULL" for the reply_block.

Parameters
clsclosure
ctxcontext
typeblock type
groupblock group to use
eocontrol flags
queryoriginal query (hash)
xqueryextrended query data (can be NULL, depending on type)
xquery_sizenumber of bytes in xquery
reply_blockresponse to validate
reply_block_sizenumber of bytes in reply block
Returns
characterization of result

Definition at line 50 of file plugin_block_consensus.c.

References GNUNET_BLOCK_evaluate(), GNUNET_BLOCK_EVALUATION_OK_MORE, GNUNET_BLOCK_EVALUATION_RESULT_INVALID, ConsensusElement::marker, and ConsensusElement::payload_type.

Referenced by libgnunet_plugin_block_consensus_init().

60 {
61  if (reply_block_size < sizeof(struct ConsensusElement))
63 
64  const struct ConsensusElement *ce = reply_block;
65 
66  if ((0 != ce->marker) ||
67  (0 == ce->payload_type))
69 
70  return GNUNET_BLOCK_evaluate(ctx,
71  type,
72  group,
73  eo,
74  query,
75  xquery,
76  xquery_size,
77  &ce[1],
78  reply_block_size - sizeof(struct ConsensusElement));
79 }
Block does not match query (invalid result)
Consensus element, either marker or payload.
uint16_t payload_type
Payload element_type, only valid if this is not a marker element.
enum GNUNET_BLOCK_EvaluationResult GNUNET_BLOCK_evaluate(struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, struct GNUNET_BLOCK_Group *group, enum GNUNET_BLOCK_EvaluationOptions eo, const struct GNUNET_HashCode *query, const void *xquery, size_t xquery_size, const void *reply_block, size_t reply_block_size)
Function called to validate a reply or a request.
Definition: block.c:337
Valid result, and there may be more.
uint8_t marker
Is this a marker element?
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Here is the call graph for this function:
Here is the caller graph for this function:

◆ block_plugin_consensus_get_key()

static int block_plugin_consensus_get_key ( void *  cls,
enum GNUNET_BLOCK_Type  type,
const void *  block,
size_t  block_size,
struct GNUNET_HashCode key 
)
static

Function called to obtain the key for a block.

Parameters
clsclosure
typeblock type
blockblock to get the key for
block_sizenumber of bytes in block
keyset to the key (query) for the given block
Returns
GNUNET_OK on success, GNUNET_SYSERR if type not supported (or if extracting a key from a block of this type does not work)

Definition at line 94 of file plugin_block_consensus.c.

References GNUNET_SYSERR.

Referenced by libgnunet_plugin_block_consensus_init().

99 {
100  return GNUNET_SYSERR;
101 }
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Here is the caller graph for this function:

◆ libgnunet_plugin_block_consensus_init()

void* libgnunet_plugin_block_consensus_init ( void *  cls)

Entry point for the plugin.

Definition at line 108 of file plugin_block_consensus.c.

References block_plugin_consensus_evaluate(), block_plugin_consensus_get_key(), GNUNET_BLOCK_PluginFunctions::evaluate, GNUNET_BLOCK_PluginFunctions::get_key, GNUNET_BLOCK_TYPE_ANY, GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT, GNUNET_new, and GNUNET_BLOCK_PluginFunctions::types.

109 {
110  static enum GNUNET_BLOCK_Type types[] =
111  {
113  GNUNET_BLOCK_TYPE_ANY /* end of list */
114  };
115  struct GNUNET_BLOCK_PluginFunctions *api;
116 
120  api->types = types;
121  return api;
122 }
static int block_plugin_consensus_get_key(void *cls, enum GNUNET_BLOCK_Type type, const void *block, size_t block_size, struct GNUNET_HashCode *key)
Function called to obtain the key for a block.
enum GNUNET_BLOCK_Type * types
0-terminated array of block types supported by this plugin.
Any type of block, used as a wildcard when searching.
GNUNET_BLOCK_EvaluationFunction evaluate
Main function of a block plugin.
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static enum GNUNET_BLOCK_EvaluationResult block_plugin_consensus_evaluate(void *cls, struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, struct GNUNET_BLOCK_Group *group, enum GNUNET_BLOCK_EvaluationOptions eo, const struct GNUNET_HashCode *query, const void *xquery, size_t xquery_size, const void *reply_block, size_t reply_block_size)
Function called to validate a reply or a request.
GNUNET_BLOCK_GetKeyFunction get_key
Obtain the key for a given block (if possible).
Block type for consensus elements.
Here is the call graph for this function:

◆ libgnunet_plugin_block_consensus_done()

void* libgnunet_plugin_block_consensus_done ( void *  cls)

Exit point from the plugin.

Definition at line 129 of file plugin_block_consensus.c.

References GNUNET_BLOCK_PluginFunctions::cls, and GNUNET_free.

130 {
131  struct GNUNET_BLOCK_PluginFunctions *api = cls;
132 
133  GNUNET_free(api);
134  return NULL;
135 }
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
void * cls
Closure for all of the callbacks.
#define GNUNET_free(ptr)
Wrapper around free.