aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_scalarproduct_service.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-05-24 19:57:15 +0000
committerChristian Grothoff <christian@grothoff.org>2014-05-24 19:57:15 +0000
commit31536a9bb75502f4c090472f188e1eec138515f7 (patch)
tree2c75617baa1ca040ddfb6a59d90831624b3512b1 /src/include/gnunet_scalarproduct_service.h
parent152cd13768915399f9e5137d78a2f75296a1b93e (diff)
downloadgnunet-31536a9bb75502f4c090472f188e1eec138515f7.tar.gz
gnunet-31536a9bb75502f4c090472f188e1eec138515f7.zip
cleaning up scalar product client API
Diffstat (limited to 'src/include/gnunet_scalarproduct_service.h')
-rw-r--r--src/include/gnunet_scalarproduct_service.h86
1 files changed, 60 insertions, 26 deletions
diff --git a/src/include/gnunet_scalarproduct_service.h b/src/include/gnunet_scalarproduct_service.h
index 63bc29f0e..c96c280c4 100644
--- a/src/include/gnunet_scalarproduct_service.h
+++ b/src/include/gnunet_scalarproduct_service.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2013 Christian Grothoff (and other contributing authors) 3 (C) 2013, 2014 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -39,13 +39,31 @@ extern "C" {
39/** 39/**
40 * Version of the scalarproduct API. 40 * Version of the scalarproduct API.
41 */ 41 */
42#define GNUNET_SCALARPRODUCT_VERSION 0x00000043 42#define GNUNET_SCALARPRODUCT_VERSION 0x00000044
43 43
44/**
45 * Result status values for the computation.
46 */
44enum GNUNET_SCALARPRODUCT_ResponseStatus 47enum GNUNET_SCALARPRODUCT_ResponseStatus
45{ 48{
49 /**
50 * The computation was successful.
51 */
46 GNUNET_SCALARPRODUCT_Status_Success = 0, 52 GNUNET_SCALARPRODUCT_Status_Success = 0,
53
54 /**
55 * We encountered some error.
56 */
47 GNUNET_SCALARPRODUCT_Status_Failure, 57 GNUNET_SCALARPRODUCT_Status_Failure,
58
59 /**
60 * We got an invalid response.
61 */
48 GNUNET_SCALARPRODUCT_Status_InvalidResponse, 62 GNUNET_SCALARPRODUCT_Status_InvalidResponse,
63
64 /**
65 * We got disconnected from the SCALARPRODUCT service.
66 */
49 GNUNET_SCALARPRODUCT_Status_ServiceDisconnected 67 GNUNET_SCALARPRODUCT_Status_ServiceDisconnected
50}; 68};
51 69
@@ -55,14 +73,27 @@ enum GNUNET_SCALARPRODUCT_ResponseStatus
55 */ 73 */
56struct GNUNET_SCALARPRODUCT_Handle; 74struct GNUNET_SCALARPRODUCT_Handle;
57 75
76
77GNUNET_NETWORK_STRUCT_BEGIN
78
58/** 79/**
59 * An element key-value pair for scalarproduct 80 * An element key-value pair for scalarproduct
60 */ 81 */
61struct GNUNET_SCALARPRODUCT_Element { 82struct GNUNET_SCALARPRODUCT_Element
62 int32_t value; 83{
63 struct GNUNET_HashCode key; 84 /**
85 * Key used to identify matching pairs of values to multiply.
86 */
87 struct GNUNET_HashCode key;
88
89 /**
90 * Value to multiply in scalar product.
91 */
92 int64_t value GNUNET_PACKED;
64}; 93};
65 94
95GNUNET_NETWORK_STRUCT_END
96
66 97
67/** 98/**
68 * Continuation called to notify client about result of the 99 * Continuation called to notify client about result of the
@@ -71,8 +102,9 @@ struct GNUNET_SCALARPRODUCT_Element {
71 * @param cls closure 102 * @param cls closure
72 * @param status Status of the request 103 * @param status Status of the request
73 */ 104 */
74typedef void (*GNUNET_SCALARPRODUCT_ContinuationWithStatus) (void *cls, 105typedef void
75 enum GNUNET_SCALARPRODUCT_ResponseStatus status); 106(*GNUNET_SCALARPRODUCT_ContinuationWithStatus) (void *cls,
107 enum GNUNET_SCALARPRODUCT_ResponseStatus status);
76 108
77 109
78/** 110/**
@@ -82,15 +114,18 @@ typedef void (*GNUNET_SCALARPRODUCT_ContinuationWithStatus) (void *cls,
82 * @param status Status of the request 114 * @param status Status of the request
83 * @param result result of the computation 115 * @param result result of the computation
84 */ 116 */
85typedef void (*GNUNET_SCALARPRODUCT_DatumProcessor) (void *cls, 117typedef void
86 enum GNUNET_SCALARPRODUCT_ResponseStatus status, 118(*GNUNET_SCALARPRODUCT_DatumProcessor) (void *cls,
87 gcry_mpi_t result); 119 enum GNUNET_SCALARPRODUCT_ResponseStatus status,
120 gcry_mpi_t result);
121
88 122
89/** 123/**
90 * Entry in the request queue per client 124 * Entry in the request queue per client
91 */ 125 */
92struct GNUNET_SCALARPRODUCT_ComputationHandle; 126struct GNUNET_SCALARPRODUCT_ComputationHandle;
93 127
128
94/** 129/**
95 * Request by Alice's client for computing a scalar product 130 * Request by Alice's client for computing a scalar product
96 * 131 *
@@ -98,20 +133,20 @@ struct GNUNET_SCALARPRODUCT_ComputationHandle;
98 * @param session_key Session key should be unique to the requesting client 133 * @param session_key Session key should be unique to the requesting client
99 * @param peer PeerID of the other peer 134 * @param peer PeerID of the other peer
100 * @param elements Array of elements of the vector 135 * @param elements Array of elements of the vector
101 * @param element_count Number of elements in the vector 136 * @param element_count Number of elements in the @a elements vector
102 * @param cont Callback function 137 * @param cont Callback function
103 * @param cont_cls Closure for the callback function 138 * @param cont_cls Closure for the @a cont callback function
104 *
105 * @return a new handle for this computation 139 * @return a new handle for this computation
106 */ 140 */
107struct GNUNET_SCALARPRODUCT_ComputationHandle * 141struct GNUNET_SCALARPRODUCT_ComputationHandle *
108GNUNET_SCALARPRODUCT_start_computation (const struct GNUNET_CONFIGURATION_Handle * cfg, 142GNUNET_SCALARPRODUCT_start_computation (const struct GNUNET_CONFIGURATION_Handle *cfg,
109 const struct GNUNET_HashCode * session_key, 143 const struct GNUNET_HashCode *session_key,
110 const struct GNUNET_PeerIdentity *peer, 144 const struct GNUNET_PeerIdentity *peer,
111 const struct GNUNET_SCALARPRODUCT_Element * elements, 145 const struct GNUNET_SCALARPRODUCT_Element *elements,
112 uint32_t element_count, 146 uint32_t element_count,
113 GNUNET_SCALARPRODUCT_DatumProcessor cont, 147 GNUNET_SCALARPRODUCT_DatumProcessor cont,
114 void * cont_cls); 148 void *cont_cls);
149
115 150
116/** 151/**
117 * Used by Bob's client to cooperate with Alice, 152 * Used by Bob's client to cooperate with Alice,
@@ -119,19 +154,18 @@ GNUNET_SCALARPRODUCT_start_computation (const struct GNUNET_CONFIGURATION_Handle
119 * @param cfg the gnunet configuration handle 154 * @param cfg the gnunet configuration handle
120 * @param session_key Session key unique to the requesting client 155 * @param session_key Session key unique to the requesting client
121 * @param elements Array of elements of the vector 156 * @param elements Array of elements of the vector
122 * @param element_count Number of elements in the vector 157 * @param element_count Number of elements in the @a elements vector
123 * @param cont Callback function 158 * @param cont Callback function
124 * @param cont_cls Closure for the callback function 159 * @param cont_cls Closure for the @a cont callback function
125 *
126 * @return a new handle for this computation 160 * @return a new handle for this computation
127 */ 161 */
128struct GNUNET_SCALARPRODUCT_ComputationHandle * 162struct GNUNET_SCALARPRODUCT_ComputationHandle *
129GNUNET_SCALARPRODUCT_accept_computation (const struct GNUNET_CONFIGURATION_Handle * cfg, 163GNUNET_SCALARPRODUCT_accept_computation (const struct GNUNET_CONFIGURATION_Handle *cfg,
130 const struct GNUNET_HashCode * key, 164 const struct GNUNET_HashCode *key,
131 const struct GNUNET_SCALARPRODUCT_Element * elements, 165 const struct GNUNET_SCALARPRODUCT_Element *elements,
132 uint32_t element_count, 166 uint32_t element_count,
133 GNUNET_SCALARPRODUCT_ContinuationWithStatus cont, 167 GNUNET_SCALARPRODUCT_ContinuationWithStatus cont,
134 void * cont_cls); 168 void *cont_cls);
135 169
136 170
137/** 171/**