aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-09-13 10:38:35 +0000
committerChristian Grothoff <christian@grothoff.org>2011-09-13 10:38:35 +0000
commit76ad1d7f3b02cfcdb4fbf373915e0c640af951f4 (patch)
treeabb9b16a1bed05e59842df5a6838838ec2564060 /src/dht/gnunet-service-dht.c
parenta7d5d8337347ccfe4165dcdf9647ea0048756a9a (diff)
downloadgnunet-76ad1d7f3b02cfcdb4fbf373915e0c640af951f4.tar.gz
gnunet-76ad1d7f3b02cfcdb4fbf373915e0c640af951f4.zip
removing dead republish functionality
Diffstat (limited to 'src/dht/gnunet-service-dht.c')
-rw-r--r--src/dht/gnunet-service-dht.c149
1 files changed, 1 insertions, 148 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index 0dc9860a0..39f3b4730 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -27,6 +27,7 @@
27 * TODO: 27 * TODO:
28 * - decide which 'benchmark'/test functions to keep 28 * - decide which 'benchmark'/test functions to keep
29 * - integrate properly with 'block' library (instead of manual bloomfiltering) 29 * - integrate properly with 'block' library (instead of manual bloomfiltering)
30 * - decide on 'stop_on_closest', 'stop_on_found', 'do_find_peer', 'paper_forwarding'
30 */ 31 */
31 32
32#include "platform.h" 33#include "platform.h"
@@ -631,20 +632,6 @@ struct RecentRequest
631 GNUNET_SCHEDULER_TaskIdentifier remove_task; 632 GNUNET_SCHEDULER_TaskIdentifier remove_task;
632}; 633};
633 634
634struct RepublishContext
635{
636 /**
637 * Key to republish.
638 */
639 GNUNET_HashCode key;
640
641 /**
642 * Type of the data.
643 */
644 unsigned int type;
645
646};
647
648 635
649/** 636/**
650 * log of the current network size estimate, used as the point where 637 * log of the current network size estimate, used as the point where
@@ -688,12 +675,6 @@ static int stop_on_found;
688static int do_find_peer; 675static int do_find_peer;
689 676
690/** 677/**
691 * Once we have stored an item in the DHT, refresh it
692 * according to our republish interval.
693 */
694static int do_republish;
695
696/**
697 * Use exactly the forwarding formula as described in 678 * Use exactly the forwarding formula as described in
698 * the paper if set to GNUNET_YES, otherwise use the 679 * the paper if set to GNUNET_YES, otherwise use the
699 * slightly modified version. 680 * slightly modified version.
@@ -779,11 +760,6 @@ static GNUNET_SCHEDULER_TaskIdentifier cleanup_task;
779static unsigned int lowest_bucket; /* Initially equal to MAX_BUCKETS - 1 */ 760static unsigned int lowest_bucket; /* Initially equal to MAX_BUCKETS - 1 */
780 761
781/** 762/**
782 * How often to republish content we have previously stored.
783 */
784static struct GNUNET_TIME_Relative dht_republish_frequency;
785
786/**
787 * The buckets (Kademlia routing table, complete with growth). 763 * The buckets (Kademlia routing table, complete with growth).
788 * Array of size MAX_BUCKET_SIZE. 764 * Array of size MAX_BUCKET_SIZE.
789 */ 765 */
@@ -2784,15 +2760,6 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg,
2784 route_message (find_msg, msg_ctx); 2760 route_message (find_msg, msg_ctx);
2785} 2761}
2786 2762
2787/**
2788 * Task used to republish data.
2789 * Forward declaration; function call loop.
2790 *
2791 * @param cls closure (a struct RepublishContext)
2792 * @param tc runtime context for this task
2793 */
2794static void
2795republish_content (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
2796 2763
2797/** 2764/**
2798 * Server handler for initiating local dht put requests 2765 * Server handler for initiating local dht put requests
@@ -2811,7 +2778,6 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg,
2811 enum GNUNET_BLOCK_Type put_type; 2778 enum GNUNET_BLOCK_Type put_type;
2812 size_t data_size; 2779 size_t data_size;
2813 int ret; 2780 int ret;
2814 struct RepublishContext *put_context;
2815 GNUNET_HashCode key; 2781 GNUNET_HashCode key;
2816 struct DHTQueryRecord *record; 2782 struct DHTQueryRecord *record;
2817 2783
@@ -2977,15 +2943,6 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg,
2977 (const char *) put_entry, put_type, 2943 (const char *) put_entry, put_type,
2978 GNUNET_TIME_absolute_ntoh (put_msg->expiration)); 2944 GNUNET_TIME_absolute_ntoh (put_msg->expiration));
2979 GNUNET_free (put_entry); 2945 GNUNET_free (put_entry);
2980
2981 if ((ret == GNUNET_YES) && (do_republish == GNUNET_YES))
2982 {
2983 put_context = GNUNET_malloc (sizeof (struct RepublishContext));
2984 memcpy (&put_context->key, &msg_ctx->key, sizeof (GNUNET_HashCode));
2985 put_context->type = put_type;
2986 GNUNET_SCHEDULER_add_delayed (dht_republish_frequency, &republish_content,
2987 put_context);
2988 }
2989 } 2946 }
2990 else 2947 else
2991 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2948 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -3662,95 +3619,6 @@ demultiplex_message (const struct GNUNET_MessageHeader *msg,
3662} 3619}
3663 3620
3664 3621
3665
3666
3667/**
3668 * Iterator for local get request results,
3669 *
3670 * @param cls closure for iterator, NULL
3671 * @param exp when does this value expire?
3672 * @param key the key this data is stored under
3673 * @param size the size of the data identified by key
3674 * @param data the actual data
3675 * @param type the type of the data
3676 *
3677 * @return GNUNET_OK to continue iteration, anything else
3678 * to stop iteration.
3679 */
3680static int
3681republish_content_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
3682 const GNUNET_HashCode * key, size_t size,
3683 const char *data, uint32_t type)
3684{
3685
3686 struct DHT_MessageContext *new_msg_ctx;
3687 struct GNUNET_DHT_PutMessage *put_msg;
3688
3689#if DEBUG_DHT
3690 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3691 "`%s:%s': Received `%s' response from datacache\n", my_short_id,
3692 "DHT", "GET");
3693#endif
3694 new_msg_ctx = GNUNET_malloc (sizeof (struct DHT_MessageContext));
3695
3696 put_msg = GNUNET_malloc (sizeof (struct GNUNET_DHT_PutMessage) + size);
3697 put_msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_PUT);
3698 put_msg->header.size = htons (sizeof (struct GNUNET_DHT_PutMessage) + size);
3699 put_msg->expiration = GNUNET_TIME_absolute_hton (exp);
3700 put_msg->type = htons (type);
3701 memcpy (&put_msg[1], data, size);
3702 new_msg_ctx->unique_id =
3703 GNUNET_ntohll (GNUNET_CRYPTO_random_u64
3704 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX));
3705 new_msg_ctx->replication = ntohl (DEFAULT_PUT_REPLICATION);
3706 new_msg_ctx->msg_options = ntohl (0);
3707 new_msg_ctx->network_size = log_of_network_size_estimate;
3708 new_msg_ctx->peer = &my_identity;
3709 new_msg_ctx->bloom =
3710 GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K);
3711 new_msg_ctx->hop_count = 0;
3712 new_msg_ctx->importance = DHT_DEFAULT_P2P_IMPORTANCE;
3713 new_msg_ctx->timeout = DHT_DEFAULT_P2P_TIMEOUT;
3714 increment_stats (STAT_PUT_START);
3715 demultiplex_message (&put_msg->header, new_msg_ctx);
3716
3717 GNUNET_free (new_msg_ctx);
3718 GNUNET_free (put_msg);
3719 return GNUNET_OK;
3720}
3721
3722/**
3723 * Task used to republish data.
3724 *
3725 * @param cls closure (a struct RepublishContext)
3726 * @param tc runtime context for this task
3727 */
3728static void
3729republish_content (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3730{
3731 struct RepublishContext *put_context = cls;
3732
3733 unsigned int results;
3734
3735 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
3736 {
3737 GNUNET_free (put_context);
3738 return;
3739 }
3740
3741 GNUNET_assert (datacache != NULL); /* If we have no datacache we never should have scheduled this! */
3742 results =
3743 GNUNET_DATACACHE_get (datacache, &put_context->key, put_context->type,
3744 &republish_content_iterator, NULL);
3745 if (results == 0) /* Data must have expired */
3746 GNUNET_free (put_context);
3747 else /* Reschedule task for next time period */
3748 GNUNET_SCHEDULER_add_delayed (dht_republish_frequency, &republish_content,
3749 put_context);
3750
3751}
3752
3753
3754/** 3622/**
3755 * Iterator over hash map entries. 3623 * Iterator over hash map entries.
3756 * 3624 *
@@ -4976,17 +4844,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
4976 malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY; 4844 malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY;
4977 } 4845 }
4978 4846
4979 dht_republish_frequency = GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY;
4980 if (GNUNET_OK ==
4981 GNUNET_CONFIGURATION_get_value_number (cfg, "DHT",
4982 "REPLICATION_FREQUENCY",
4983 &temp_config_num))
4984 {
4985 dht_republish_frequency =
4986 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES,
4987 temp_config_num);
4988 }
4989
4990 if (GNUNET_OK == 4847 if (GNUNET_OK ==
4991 GNUNET_CONFIGURATION_get_value_number (cfg, "DHT", "bucket_size", 4848 GNUNET_CONFIGURATION_get_value_number (cfg, "DHT", "bucket_size",
4992 &temp_config_num)) 4849 &temp_config_num))
@@ -5007,10 +4864,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
5007 malicious_dropper = GNUNET_YES; 4864 malicious_dropper = GNUNET_YES;
5008 } 4865 }
5009 4866
5010 if (GNUNET_YES ==
5011 GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "republish"))
5012 do_republish = GNUNET_NO;
5013
5014 if (GNUNET_NO == 4867 if (GNUNET_NO ==
5015 GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "do_find_peer")) 4868 GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "do_find_peer"))
5016 { 4869 {