aboutsummaryrefslogtreecommitdiff
path: root/src/consensus/gnunet-service-consensus.c
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2015-12-10 16:31:20 +0000
committerFlorian Dold <florian.dold@gmail.com>2015-12-10 16:31:20 +0000
commit79d5251a7a1f15cba527d1f6d6d584499e678a82 (patch)
treee1ddf5268d218fb1fd3fd5451da33f2d617eee07 /src/consensus/gnunet-service-consensus.c
parentc283a6775a6438f7da5c3173b3993f78d1369a7d (diff)
downloadgnunet-79d5251a7a1f15cba527d1f6d6d584499e678a82.tar.gz
gnunet-79d5251a7a1f15cba527d1f6d6d584499e678a82.zip
More statistics.
Diffstat (limited to 'src/consensus/gnunet-service-consensus.c')
-rw-r--r--src/consensus/gnunet-service-consensus.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c
index b1c8466cb..fe69b60b6 100644
--- a/src/consensus/gnunet-service-consensus.c
+++ b/src/consensus/gnunet-service-consensus.c
@@ -29,6 +29,7 @@
29#include "gnunet_protocols.h" 29#include "gnunet_protocols.h"
30#include "gnunet_applications.h" 30#include "gnunet_applications.h"
31#include "gnunet_set_service.h" 31#include "gnunet_set_service.h"
32#include "gnunet_statistics_service.h"
32#include "gnunet_consensus_service.h" 33#include "gnunet_consensus_service.h"
33#include "consensus_protocol.h" 34#include "consensus_protocol.h"
34#include "consensus.h" 35#include "consensus.h"
@@ -485,6 +486,11 @@ static struct GNUNET_SERVER_Handle *srv;
485 */ 486 */
486static struct GNUNET_PeerIdentity my_peer; 487static struct GNUNET_PeerIdentity my_peer;
487 488
489/**
490 * Statistics handle.
491 */
492struct GNUNET_STATISTICS_Handle *statistics;
493
488 494
489static void 495static void
490finish_task (struct TaskEntry *task); 496finish_task (struct TaskEntry *task);
@@ -1226,6 +1232,14 @@ commit_set (struct ConsensusSession *session,
1226 struct Evilness evil; 1232 struct Evilness evil;
1227 1233
1228 get_evilness (session, &evil); 1234 get_evilness (session, &evil);
1235 if (EVILNESS_NONE != evil.type)
1236 {
1237 /* Useful for evaluation */
1238 GNUNET_STATISTICS_set (statistics,
1239 "is evil",
1240 1,
1241 GNUNET_NO);
1242 }
1229 switch (evil.type) 1243 switch (evil.type)
1230 { 1244 {
1231 case EVILNESS_CRAM_ALL: 1245 case EVILNESS_CRAM_ALL:
@@ -1240,7 +1254,8 @@ commit_set (struct ConsensusSession *session,
1240 GNUNET_SET_commit (setop->op, set->h); 1254 GNUNET_SET_commit (setop->op, set->h);
1241 break; 1255 break;
1242 } 1256 }
1243 if ((EVILNESS_CRAM_LEAD == evil.type) && (PHASE_KIND_GRADECAST_LEADER != task->key.kind)) 1257 if ((EVILNESS_CRAM_LEAD == evil.type) &&
1258 ((PHASE_KIND_GRADECAST_LEADER != task->key.kind) || SET_KIND_CURRENT != set->key.set_kind))
1244 { 1259 {
1245 GNUNET_SET_commit (setop->op, set->h); 1260 GNUNET_SET_commit (setop->op, set->h);
1246 break; 1261 break;
@@ -1282,6 +1297,10 @@ commit_set (struct ConsensusSession *session,
1282 debug_str_task_key (&task->key)); 1297 debug_str_task_key (&task->key));
1283#endif 1298#endif
1284 } 1299 }
1300 GNUNET_STATISTICS_update (statistics,
1301 "# stuffed elements",
1302 evil.num,
1303 GNUNET_NO);
1285 GNUNET_SET_commit (setop->op, set->h); 1304 GNUNET_SET_commit (setop->op, set->h);
1286 break; 1305 break;
1287 case EVILNESS_SLACK: 1306 case EVILNESS_SLACK:
@@ -1842,12 +1861,7 @@ task_start_reconcile (struct TaskEntry *task)
1842 set_result_cb, 1861 set_result_cb,
1843 task); 1862 task);
1844 1863
1845 if (GNUNET_OK != GNUNET_SET_commit (setop->op, input->h)) 1864 commit_set (session, task);
1846 {
1847 GNUNET_break (0);
1848 /* XXX: cleanup? */
1849 return;
1850 }
1851 } 1865 }
1852 else if (task->key.peer2 == session->local_peer_idx) 1866 else if (task->key.peer2 == session->local_peer_idx)
1853 { 1867 {
@@ -3006,6 +3020,7 @@ shutdown_task (void *cls,
3006 while (NULL != sessions_head) 3020 while (NULL != sessions_head)
3007 destroy_session (sessions_head); 3021 destroy_session (sessions_head);
3008 3022
3023 GNUNET_STATISTICS_destroy (statistics, GNUNET_YES);
3009 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "handled shutdown request\n"); 3024 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "handled shutdown request\n");
3010} 3025}
3011 3026
@@ -3058,6 +3073,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
3058 GNUNET_SCHEDULER_shutdown (); 3073 GNUNET_SCHEDULER_shutdown ();
3059 return; 3074 return;
3060 } 3075 }
3076 statistics = GNUNET_STATISTICS_create ("consensus", cfg);
3061 GNUNET_SERVER_add_handlers (server, server_handlers); 3077 GNUNET_SERVER_add_handlers (server, server_handlers);
3062 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); 3078 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL);
3063 GNUNET_SERVER_disconnect_notify (server, handle_client_disconnect, NULL); 3079 GNUNET_SERVER_disconnect_notify (server, handle_client_disconnect, NULL);