GNUnet  0.10.x
Data Structures | Typedefs
Block plugin API

To be implemented by applications storing data in the DHT. More...

Data Structures

struct  GNUNET_BLOCK_Group
 Block group data. More...
 
struct  GNUNET_BLOCK_PluginFunctions
 Each plugin is required to return a pointer to a struct of this type as the return value from its entry point. More...
 

Typedefs

typedef void(* GNUNET_BLOCK_GroupMarkSeenFunction) (struct GNUNET_BLOCK_Group *bg, const struct GNUNET_HashCode *seen_results, unsigned int seen_results_count)
 Mark elements as "seen" using a hash of the element. More...
 
typedef int(* GNUNET_BLOCK_GroupMergeFunction) (struct GNUNET_BLOCK_Group *bg1, const struct GNUNET_BLOCK_Group *bg2)
 Merge two groups, if possible. More...
 
typedef int(* GNUNET_BLOCK_GroupSerializeFunction) (struct GNUNET_BLOCK_Group *bg, uint32_t *nonce, void **raw_data, size_t *raw_data_size)
 Serialize state of a block group. More...
 
typedef void(* GNUNET_BLOCK_GroupDestroyFunction) (struct GNUNET_BLOCK_Group *bg)
 Destroy resources used by a block group. More...
 
typedef struct GNUNET_BLOCK_Group *(* GNUNET_BLOCK_GroupCreateFunction) (void *cls, enum GNUNET_BLOCK_Type type, uint32_t nonce, const void *raw_data, size_t raw_data_size, va_list va)
 Create a new block group. More...
 
typedef enum GNUNET_BLOCK_EvaluationResult(* GNUNET_BLOCK_EvaluationFunction) (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...
 
typedef int(* GNUNET_BLOCK_GetKeyFunction) (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...
 

Detailed Description

To be implemented by applications storing data in the DHT.

Each block plugin must conform to the API specified by this header.

Typedef Documentation

◆ GNUNET_BLOCK_GroupMarkSeenFunction

typedef void(* GNUNET_BLOCK_GroupMarkSeenFunction) (struct GNUNET_BLOCK_Group *bg, const struct GNUNET_HashCode *seen_results, unsigned int seen_results_count)

Mark elements as "seen" using a hash of the element.

Not supported by all block plugins.

Parameters
bggroup to update
seen_resultsresults already seen
seen_results_countnumber of entries in seen_results

Definition at line 51 of file gnunet_block_plugin.h.

◆ GNUNET_BLOCK_GroupMergeFunction

typedef int(* GNUNET_BLOCK_GroupMergeFunction) (struct GNUNET_BLOCK_Group *bg1, const struct GNUNET_BLOCK_Group *bg2)

Merge two groups, if possible.

Not supported by all block plugins, can also fail if the nonces were different.

Parameters
bg1group to update
bg2group to merge into bg1
Returns
GNUNET_OK on success, GNUNET_NO if the nonces were different and thus we failed.

Definition at line 66 of file gnunet_block_plugin.h.

◆ GNUNET_BLOCK_GroupSerializeFunction

typedef int(* GNUNET_BLOCK_GroupSerializeFunction) (struct GNUNET_BLOCK_Group *bg, uint32_t *nonce, void **raw_data, size_t *raw_data_size)

Serialize state of a block group.

Parameters
bggroup to serialize
[out]nonceset to the nonce of the bg
[out]raw_dataset to the serialized state
[out]raw_data_sizeset to the number of bytes in raw_data
Returns
GNUNET_OK on success, GNUNET_NO if serialization is not supported, GNUNET_SYSERR on error

Definition at line 81 of file gnunet_block_plugin.h.

◆ GNUNET_BLOCK_GroupDestroyFunction

typedef void(* GNUNET_BLOCK_GroupDestroyFunction) (struct GNUNET_BLOCK_Group *bg)

Destroy resources used by a block group.

Parameters
bggroup to destroy, NULL is allowed

Definition at line 93 of file gnunet_block_plugin.h.

◆ GNUNET_BLOCK_GroupCreateFunction

typedef struct GNUNET_BLOCK_Group*(* GNUNET_BLOCK_GroupCreateFunction) (void *cls, enum GNUNET_BLOCK_Type type, uint32_t nonce, const void *raw_data, size_t raw_data_size, va_list va)

Create a new block group.

Parameters
ctxblock context in which the block group is created
typetype of the block for which we are creating the group
noncerandom value used to seed the group creation
raw_dataoptional serialized prior state of the group, NULL if unavailable/fresh
raw_data_sizenumber of bytes in raw_data, 0 if unavailable/fresh
vavariable arguments specific to type
Returns
block group handle, NULL if block groups are not supported by this type of block (this is not an error)

Definition at line 155 of file gnunet_block_plugin.h.

◆ GNUNET_BLOCK_EvaluationFunction

typedef enum GNUNET_BLOCK_EvaluationResult(* GNUNET_BLOCK_EvaluationFunction) (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.

For request evaluation, simply pass "NULL" for the reply_block. Note that it is assumed that the reply has already been matched to the key (and signatures checked) as it would be done with the "get_key" function.

Parameters
clsclosure
ctxblock context
typeblock type
groupwhich block group to use for evaluation
eoevaluation options to control evaluation
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 183 of file gnunet_block_plugin.h.

◆ GNUNET_BLOCK_GetKeyFunction

typedef int(* GNUNET_BLOCK_GetKeyFunction) (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.

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_YES on success, GNUNET_NO if the block is malformed GNUNET_SYSERR if type not supported (or if extracting a key from a block of this type does not work)

Definition at line 209 of file gnunet_block_plugin.h.