aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht_neighbours.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-09-26 21:24:03 +0000
committerChristian Grothoff <christian@grothoff.org>2016-09-26 21:24:03 +0000
commit7b00dd51218edbd9182caa664cfce185edc2cc45 (patch)
tree2cea8a9d7085aa6e3d16256f18f7c77f3320bb75 /src/dht/gnunet-service-dht_neighbours.c
parent60ff113fe4e7bb71d5696063b9a9b81eba60a108 (diff)
downloadgnunet-7b00dd51218edbd9182caa664cfce185edc2cc45.tar.gz
gnunet-7b00dd51218edbd9182caa664cfce185edc2cc45.zip
porting xdht to new service API, major code de-duplication effort
Diffstat (limited to 'src/dht/gnunet-service-dht_neighbours.c')
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c59
1 files changed, 52 insertions, 7 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index 39fb43495..574ed9ad0 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -1255,8 +1255,8 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
1255 gettext_noop ("# PUT requests routed"), 1255 gettext_noop ("# PUT requests routed"),
1256 1, 1256 1,
1257 GNUNET_NO); 1257 GNUNET_NO);
1258 target_count = 1258 target_count
1259 get_target_peers (key, 1259 = get_target_peers (key,
1260 bf, 1260 bf,
1261 hop_count, 1261 hop_count,
1262 desired_replication_level, 1262 desired_replication_level,
@@ -1768,9 +1768,13 @@ handle_dht_p2p_put (void *cls,
1768 /* store locally */ 1768 /* store locally */
1769 if ((0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) || 1769 if ((0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) ||
1770 (am_closest_peer (&put->key, bf))) 1770 (am_closest_peer (&put->key, bf)))
1771 GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh 1771 GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (put->expiration_time),
1772 (put->expiration_time), &put->key, putlen, pp, 1772 &put->key,
1773 ntohl (put->type), payload_size, payload); 1773 putlen,
1774 pp,
1775 ntohl (put->type),
1776 payload_size,
1777 payload);
1774 /* route to other peers */ 1778 /* route to other peers */
1775 forwarded = GDS_NEIGHBOURS_handle_put (ntohl (put->type), 1779 forwarded = GDS_NEIGHBOURS_handle_put (ntohl (put->type),
1776 options, 1780 options,
@@ -1913,6 +1917,44 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender,
1913 1917
1914 1918
1915/** 1919/**
1920 * Handle a result from local datacache for a GET operation.
1921 *
1922 * @param cls the `struct ClientHandle` of the client doing the query
1923 * @param type type of the block
1924 * @param expiration_time when does the content expire
1925 * @param key key for the content
1926 * @param put_path_length number of entries in @a put_path
1927 * @param put_path peers the original PUT traversed (if tracked)
1928 * @param get_path_length number of entries in @a get_path
1929 * @param get_path peers this reply has traversed so far (if tracked)
1930 * @param data payload of the reply
1931 * @param data_size number of bytes in @a data
1932 */
1933static void
1934handle_local_result (void *cls,
1935 enum GNUNET_BLOCK_Type type,
1936 struct GNUNET_TIME_Absolute expiration_time,
1937 const struct GNUNET_HashCode *key,
1938 unsigned int put_path_length,
1939 const struct GNUNET_PeerIdentity *put_path,
1940 unsigned int get_path_length,
1941 const struct GNUNET_PeerIdentity *get_path,
1942 const void *data,
1943 size_t data_size)
1944{
1945 // FIXME: we can probably do better here by
1946 // passing the peer that did the query in the closure...
1947 GDS_ROUTING_process (NULL,
1948 type,
1949 expiration_time,
1950 key,
1951 put_path_length, put_path,
1952 0, NULL,
1953 data, data_size);
1954}
1955
1956
1957/**
1916 * Check validity of p2p get request. 1958 * Check validity of p2p get request.
1917 * 1959 *
1918 * @param cls closure with the `struct PeerInfo` of the sender 1960 * @param cls closure with the `struct PeerInfo` of the sender
@@ -2067,7 +2109,9 @@ handle_dht_p2p_get (void *cls,
2067 xquery, 2109 xquery,
2068 xquery_size, 2110 xquery_size,
2069 &reply_bf, 2111 &reply_bf,
2070 get->bf_mutator); 2112 get->bf_mutator,
2113 &handle_local_result,
2114 NULL);
2071 } 2115 }
2072 } 2116 }
2073 else 2117 else
@@ -2276,7 +2320,8 @@ handle_dht_p2p_result (void *cls,
2276 data); 2320 data);
2277 } 2321 }
2278 /* forward to other peers */ 2322 /* forward to other peers */
2279 GDS_ROUTING_process (type, 2323 GDS_ROUTING_process (NULL,
2324 type,
2280 GNUNET_TIME_absolute_ntoh (prm->expiration_time), 2325 GNUNET_TIME_absolute_ntoh (prm->expiration_time),
2281 &prm->key, 2326 &prm->key,
2282 put_path_length, 2327 put_path_length,