aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-dht-put.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht/gnunet-dht-put.c')
-rw-r--r--src/dht/gnunet-dht-put.c50
1 files changed, 23 insertions, 27 deletions
diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c
index 02a4fc217..b76b92c2b 100644
--- a/src/dht/gnunet-dht-put.c
+++ b/src/dht/gnunet-dht-put.c
@@ -76,10 +76,10 @@ static void
76shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 76shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
77{ 77{
78 if (dht_handle != NULL) 78 if (dht_handle != NULL)
79 { 79 {
80 GNUNET_DHT_disconnect (dht_handle); 80 GNUNET_DHT_disconnect (dht_handle);
81 dht_handle = NULL; 81 dht_handle = NULL;
82 } 82 }
83} 83}
84 84
85/** 85/**
@@ -92,8 +92,7 @@ void
92message_sent_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 92message_sent_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
93{ 93{
94 if (verbose) 94 if (verbose)
95 fprintf (stderr, 95 fprintf (stderr, _("PUT request sent!\n"));
96 _("PUT request sent!\n"));
97 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); 96 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
98} 97}
99 98
@@ -113,40 +112,37 @@ run (void *cls,
113 struct GNUNET_TIME_Relative timeout; 112 struct GNUNET_TIME_Relative timeout;
114 struct GNUNET_TIME_Absolute expiration; 113 struct GNUNET_TIME_Absolute expiration;
115 GNUNET_HashCode key; 114 GNUNET_HashCode key;
115
116 cfg = c; 116 cfg = c;
117 117
118 if ( (query_key == NULL) || (data == NULL) ) 118 if ((query_key == NULL) || (data == NULL))
119 { 119 {
120 fprintf (stderr, 120 fprintf (stderr, _("Must provide KEY and DATA for DHT put!\n"));
121 _("Must provide KEY and DATA for DHT put!\n")); 121 ret = 1;
122 ret = 1; 122 return;
123 return; 123 }
124 }
125 124
126 dht_handle = GNUNET_DHT_connect (cfg, 1); 125 dht_handle = GNUNET_DHT_connect (cfg, 1);
127 if (dht_handle == NULL) 126 if (dht_handle == NULL)
128 { 127 {
129 fprintf (stderr, 128 fprintf (stderr, _("Could not connect to %s service!\n"), "DHT");
130 _("Could not connect to %s service!\n"), 129 ret = 1;
131 "DHT"); 130 return;
132 ret = 1; 131 }
133 return;
134 }
135 else if (verbose) 132 else if (verbose)
136 fprintf (stderr, 133 fprintf (stderr, _("Connected to %s service!\n"), "DHT");
137 _("Connected to %s service!\n"), "DHT");
138 134
139 if (query_type == GNUNET_BLOCK_TYPE_ANY) /* Type of data not set */ 135 if (query_type == GNUNET_BLOCK_TYPE_ANY) /* Type of data not set */
140 query_type = GNUNET_BLOCK_TYPE_TEST; 136 query_type = GNUNET_BLOCK_TYPE_TEST;
141 137
142 GNUNET_CRYPTO_hash (query_key, strlen (query_key), &key); 138 GNUNET_CRYPTO_hash (query_key, strlen (query_key), &key);
143 139
144 timeout = 140 timeout =
145 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, timeout_request); 141 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, timeout_request);
146 expiration = 142 expiration =
147 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply 143 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply
148 (GNUNET_TIME_UNIT_SECONDS, 144 (GNUNET_TIME_UNIT_SECONDS,
149 expiration_seconds)); 145 expiration_seconds));
150 146
151 if (verbose) 147 if (verbose)
152 fprintf (stderr, _("Issuing put request for `%s' with data `%s'!\n"), 148 fprintf (stderr, _("Issuing put request for `%s' with data `%s'!\n"),