diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-07 08:47:44 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-07 08:47:44 +0000 |
commit | 87da62e2d7df26addf33263ef2b6ba4c27faa44b (patch) | |
tree | 1325fbf749651c0a35b405324e27cb2edbb0387e | |
parent | 8b878c24c4696c55773bdd78573b7710019558a6 (diff) | |
download | gnunet-87da62e2d7df26addf33263ef2b6ba4c27faa44b.tar.gz gnunet-87da62e2d7df26addf33263ef2b6ba4c27faa44b.zip |
implement revocation broadcasting (part of #3057)
-rw-r--r-- | src/revocation/gnunet-service-revocation.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c index 16c3640da..c6e3152ba 100644 --- a/src/revocation/gnunet-service-revocation.c +++ b/src/revocation/gnunet-service-revocation.c | |||
@@ -31,8 +31,7 @@ | |||
31 | * peers that connect. | 31 | * peers that connect. |
32 | * | 32 | * |
33 | * TODO: | 33 | * TODO: |
34 | * - broadcast p2p revocations | 34 | * - handle p2p connect (trigger SET union, #3057) |
35 | * - handle p2p connect (trigger SET union) | ||
36 | * - optimization: avoid sending revocation back to peer that we got it from; | 35 | * - optimization: avoid sending revocation back to peer that we got it from; |
37 | * - optimization: have randomized delay in sending revocations to other peers | 36 | * - optimization: have randomized delay in sending revocations to other peers |
38 | * to make it rare to traverse each link twice (NSE-style) | 37 | * to make it rare to traverse each link twice (NSE-style) |
@@ -58,20 +57,15 @@ struct PeerEntry | |||
58 | { | 57 | { |
59 | 58 | ||
60 | /** | 59 | /** |
61 | * Core handle for sending messages to this peer. | 60 | * Queue for sending messages to this peer. |
62 | */ | 61 | */ |
63 | struct GNUNET_CORE_TransmitHandle *th; | 62 | struct GNUNET_MQ_Handle *mq; |
64 | 63 | ||
65 | /** | 64 | /** |
66 | * What is the identity of the peer? | 65 | * What is the identity of the peer? |
67 | */ | 66 | */ |
68 | struct GNUNET_PeerIdentity id; | 67 | struct GNUNET_PeerIdentity id; |
69 | 68 | ||
70 | /** | ||
71 | * Task scheduled to send message to this peer. | ||
72 | */ | ||
73 | GNUNET_SCHEDULER_TaskIdentifier transmit_task; | ||
74 | |||
75 | }; | 69 | }; |
76 | 70 | ||
77 | 71 | ||
@@ -99,7 +93,7 @@ static struct GNUNET_STATISTICS_Handle *stats; | |||
99 | /** | 93 | /** |
100 | * Handle to the core service (for flooding) | 94 | * Handle to the core service (for flooding) |
101 | */ | 95 | */ |
102 | static struct GNUNET_CORE_Handle *coreAPI; | 96 | static struct GNUNET_CORE_Handle *core_api; |
103 | 97 | ||
104 | /** | 98 | /** |
105 | * Map of all connected peers. | 99 | * Map of all connected peers. |
@@ -217,7 +211,14 @@ do_flood (void *cls, | |||
217 | const struct GNUNET_PeerIdentity *target, | 211 | const struct GNUNET_PeerIdentity *target, |
218 | void *value) | 212 | void *value) |
219 | { | 213 | { |
220 | GNUNET_break (0); // FIXME: not implemented | 214 | const struct RevokeMessage *rm = cls; |
215 | struct PeerEntry *pe = value; | ||
216 | struct GNUNET_MQ_Envelope *e; | ||
217 | struct RevokeMessage *cp; | ||
218 | |||
219 | e = GNUNET_MQ_msg (cp, GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE); | ||
220 | *cp = *rm; | ||
221 | GNUNET_MQ_send (pe->mq, e); | ||
221 | return GNUNET_OK; | 222 | return GNUNET_OK; |
222 | } | 223 | } |
223 | 224 | ||
@@ -376,11 +377,12 @@ handle_core_connect (void *cls, | |||
376 | GNUNET_i2s (peer)); | 377 | GNUNET_i2s (peer)); |
377 | peer_entry = GNUNET_new (struct PeerEntry); | 378 | peer_entry = GNUNET_new (struct PeerEntry); |
378 | peer_entry->id = *peer; | 379 | peer_entry->id = *peer; |
380 | peer_entry->mq = GNUNET_CORE_mq_create (core_api, peer); | ||
379 | GNUNET_assert (GNUNET_OK == | 381 | GNUNET_assert (GNUNET_OK == |
380 | GNUNET_CONTAINER_multipeermap_put (peers, peer, | 382 | GNUNET_CONTAINER_multipeermap_put (peers, peer, |
381 | peer_entry, | 383 | peer_entry, |
382 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 384 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
383 | GNUNET_break (0); // FIXME: implement revocation set union on connect! | 385 | // GNUNET_break (0); // FIXME: implement revocation set union on connect! |
384 | #if 0 | 386 | #if 0 |
385 | peer_entry->transmit_task = | 387 | peer_entry->transmit_task = |
386 | GNUNET_SCHEDULER_add_delayed (get_transmit_delay (-1), &transmit_task_cb, | 388 | GNUNET_SCHEDULER_add_delayed (get_transmit_delay (-1), &transmit_task_cb, |
@@ -415,17 +417,13 @@ handle_core_disconnect (void *cls, | |||
415 | GNUNET_assert (GNUNET_YES == | 417 | GNUNET_assert (GNUNET_YES == |
416 | GNUNET_CONTAINER_multipeermap_remove (peers, peer, | 418 | GNUNET_CONTAINER_multipeermap_remove (peers, peer, |
417 | pos)); | 419 | pos)); |
420 | GNUNET_MQ_destroy (pos->mq); | ||
418 | #if 0 | 421 | #if 0 |
419 | if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK) | 422 | if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK) |
420 | { | 423 | { |
421 | GNUNET_SCHEDULER_cancel (pos->transmit_task); | 424 | GNUNET_SCHEDULER_cancel (pos->transmit_task); |
422 | pos->transmit_task = GNUNET_SCHEDULER_NO_TASK; | 425 | pos->transmit_task = GNUNET_SCHEDULER_NO_TASK; |
423 | } | 426 | } |
424 | if (NULL != pos->th) | ||
425 | { | ||
426 | GNUNET_CORE_notify_transmit_ready_cancel (pos->th); | ||
427 | pos->th = NULL; | ||
428 | } | ||
429 | #endif | 427 | #endif |
430 | GNUNET_free (pos); | 428 | GNUNET_free (pos); |
431 | GNUNET_STATISTICS_update (stats, "# peers connected", -1, GNUNET_NO); | 429 | GNUNET_STATISTICS_update (stats, "# peers connected", -1, GNUNET_NO); |
@@ -465,10 +463,10 @@ shutdown_task (void *cls, | |||
465 | GNUNET_SET_destroy (revocation_set); | 463 | GNUNET_SET_destroy (revocation_set); |
466 | revocation_set = NULL; | 464 | revocation_set = NULL; |
467 | } | 465 | } |
468 | if (NULL != coreAPI) | 466 | if (NULL != core_api) |
469 | { | 467 | { |
470 | GNUNET_CORE_disconnect (coreAPI); | 468 | GNUNET_CORE_disconnect (core_api); |
471 | coreAPI = NULL; | 469 | core_api = NULL; |
472 | } | 470 | } |
473 | if (NULL != stats) | 471 | if (NULL != stats) |
474 | { | 472 | { |
@@ -639,7 +637,7 @@ run (void *cls, | |||
639 | peers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); | 637 | peers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); |
640 | GNUNET_SERVER_add_handlers (srv, handlers); | 638 | GNUNET_SERVER_add_handlers (srv, handlers); |
641 | /* Connect to core service and register core handlers */ | 639 | /* Connect to core service and register core handlers */ |
642 | coreAPI = GNUNET_CORE_connect (cfg, /* Main configuration */ | 640 | core_api = GNUNET_CORE_connect (cfg, /* Main configuration */ |
643 | NULL, /* Closure passed to functions */ | 641 | NULL, /* Closure passed to functions */ |
644 | &core_init, /* Call core_init once connected */ | 642 | &core_init, /* Call core_init once connected */ |
645 | &handle_core_connect, /* Handle connects */ | 643 | &handle_core_connect, /* Handle connects */ |
@@ -649,7 +647,7 @@ run (void *cls, | |||
649 | NULL, /* Don't want notified about all outbound messages */ | 647 | NULL, /* Don't want notified about all outbound messages */ |
650 | GNUNET_NO, /* For header only outbound notification */ | 648 | GNUNET_NO, /* For header only outbound notification */ |
651 | core_handlers); /* Register these handlers */ | 649 | core_handlers); /* Register these handlers */ |
652 | if (NULL == coreAPI) | 650 | if (NULL == core_api) |
653 | { | 651 | { |
654 | GNUNET_SCHEDULER_shutdown (); | 652 | GNUNET_SCHEDULER_shutdown (); |
655 | return; | 653 | return; |