diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-02-22 11:10:02 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-02-22 11:10:02 +0100 |
commit | 8000747074b82caeacb0f43710940220d9840d37 (patch) | |
tree | ef0f40343a0acf45894e9cfc8bc2d571fa3db8e9 /src/dht | |
parent | cccdf454e79ab779989876135b964f039c647a10 (diff) | |
download | gnunet-8000747074b82caeacb0f43710940220d9840d37.tar.gz gnunet-8000747074b82caeacb0f43710940220d9840d37.zip |
clean up new block logic, avoid direct linkage against blockgroup lib from DHT service
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/Makefile.am | 1 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_neighbours.c | 70 | ||||
-rw-r--r-- | src/dht/plugin_block_dht.c | 2 |
3 files changed, 40 insertions, 33 deletions
diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am index 4216af400..b95083c85 100644 --- a/src/dht/Makefile.am +++ b/src/dht/Makefile.am | |||
@@ -82,7 +82,6 @@ gnunet_service_dht_LDADD = \ | |||
82 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ | 82 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ |
83 | $(top_builddir)/src/hello/libgnunethello.la \ | 83 | $(top_builddir)/src/hello/libgnunethello.la \ |
84 | $(top_builddir)/src/block/libgnunetblock.la \ | 84 | $(top_builddir)/src/block/libgnunetblock.la \ |
85 | $(top_builddir)/src/block/libgnunetblockgroup.la \ | ||
86 | $(top_builddir)/src/datacache/libgnunetdatacache.la \ | 85 | $(top_builddir)/src/datacache/libgnunetdatacache.la \ |
87 | $(top_builddir)/src/util/libgnunetutil.la \ | 86 | $(top_builddir)/src/util/libgnunetutil.la \ |
88 | -lm | 87 | -lm |
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index 1bbc95a06..975872f1b 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_block_lib.h" | 29 | #include "gnunet_block_lib.h" |
30 | #include "gnunet_block_group_lib.h" | ||
31 | #include "gnunet_hello_lib.h" | 30 | #include "gnunet_hello_lib.h" |
32 | #include "gnunet_constants.h" | 31 | #include "gnunet_constants.h" |
33 | #include "gnunet_protocols.h" | 32 | #include "gnunet_protocols.h" |
@@ -622,8 +621,9 @@ add_known_to_bloom (void *cls, | |||
622 | GNUNET_CRYPTO_hash (key, | 621 | GNUNET_CRYPTO_hash (key, |
623 | sizeof (struct GNUNET_PeerIdentity), | 622 | sizeof (struct GNUNET_PeerIdentity), |
624 | &key_hash); | 623 | &key_hash); |
625 | GNUNET_BLOCK_GROUP_bf_test_and_set (bg, | 624 | GNUNET_BLOCK_group_set_seen (bg, |
626 | &key_hash); | 625 | &key_hash, |
626 | 1); | ||
627 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 627 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
628 | "Adding known peer (%s) to bloomfilter for FIND PEER\n", | 628 | "Adding known peer (%s) to bloomfilter for FIND PEER\n", |
629 | GNUNET_i2s (key)); | 629 | GNUNET_i2s (key)); |
@@ -656,14 +656,12 @@ send_find_peer_message (void *cls) | |||
656 | newly_found_peers = 0; | 656 | newly_found_peers = 0; |
657 | return; | 657 | return; |
658 | } | 658 | } |
659 | bg = GNUNET_BLOCK_GROUP_bf_create (NULL, | 659 | bg = GNUNET_BLOCK_group_create (GDS_block_context, |
660 | DHT_BLOOM_SIZE, | 660 | GNUNET_BLOCK_TYPE_DHT_HELLO, |
661 | GNUNET_CONSTANTS_BLOOMFILTER_K, | 661 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
662 | GNUNET_BLOCK_TYPE_DHT_HELLO, | 662 | UINT32_MAX), |
663 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 663 | NULL, |
664 | UINT32_MAX), | 664 | 0); |
665 | NULL, | ||
666 | 0); | ||
667 | GNUNET_CONTAINER_multipeermap_iterate (all_connected_peers, | 665 | GNUNET_CONTAINER_multipeermap_iterate (all_connected_peers, |
668 | &add_known_to_bloom, | 666 | &add_known_to_bloom, |
669 | bg); | 667 | bg); |
@@ -1839,22 +1837,26 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender, | |||
1839 | struct PeerInfo *peer; | 1837 | struct PeerInfo *peer; |
1840 | unsigned int choice; | 1838 | unsigned int choice; |
1841 | const struct GNUNET_HELLO_Message *hello; | 1839 | const struct GNUNET_HELLO_Message *hello; |
1840 | size_t hello_size; | ||
1842 | 1841 | ||
1843 | /* first, check about our own HELLO */ | 1842 | /* first, check about our own HELLO */ |
1844 | if (NULL != GDS_my_hello) | 1843 | if (NULL != GDS_my_hello) |
1845 | { | 1844 | { |
1846 | if (GNUNET_YES != | 1845 | hello_size = GNUNET_HELLO_size ((const struct GNUNET_HELLO_Message *) GDS_my_hello); |
1847 | GNUNET_BLOCK_GROUP_bf_test_and_set (bg, | 1846 | GNUNET_break (hello_size >= sizeof (struct GNUNET_MessageHeader)); |
1848 | &my_identity_hash)) | 1847 | if (GNUNET_BLOCK_EVALUATION_OK_MORE == |
1848 | GNUNET_BLOCK_evaluate (GDS_block_context, | ||
1849 | GNUNET_BLOCK_TYPE_DHT_HELLO, | ||
1850 | bg, | ||
1851 | GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO, | ||
1852 | &my_identity_hash, | ||
1853 | NULL, 0, | ||
1854 | GDS_my_hello, | ||
1855 | hello_size)) | ||
1849 | { | 1856 | { |
1850 | size_t hello_size; | ||
1851 | |||
1852 | hello_size = GNUNET_HELLO_size ((const struct GNUNET_HELLO_Message *) GDS_my_hello); | ||
1853 | GNUNET_break (hello_size >= sizeof (struct GNUNET_MessageHeader)); | ||
1854 | GDS_NEIGHBOURS_handle_reply (sender, | 1857 | GDS_NEIGHBOURS_handle_reply (sender, |
1855 | GNUNET_BLOCK_TYPE_DHT_HELLO, | 1858 | GNUNET_BLOCK_TYPE_DHT_HELLO, |
1856 | GNUNET_TIME_relative_to_absolute | 1859 | GNUNET_TIME_relative_to_absolute (hello_expiration), |
1857 | (hello_expiration), | ||
1858 | key, | 1860 | key, |
1859 | 0, | 1861 | 0, |
1860 | NULL, | 1862 | NULL, |
@@ -1910,10 +1912,17 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender, | |||
1910 | if (NULL == peer) | 1912 | if (NULL == peer) |
1911 | peer = bucket->head; | 1913 | peer = bucket->head; |
1912 | hello = GDS_HELLO_get (peer->id); | 1914 | hello = GDS_HELLO_get (peer->id); |
1915 | hello_size = GNUNET_HELLO_size (hello); | ||
1913 | } while ( (NULL == hello) || | 1916 | } while ( (NULL == hello) || |
1914 | (GNUNET_YES == | 1917 | (GNUNET_BLOCK_EVALUATION_OK_MORE != |
1915 | GNUNET_BLOCK_GROUP_bf_test_and_set (bg, | 1918 | GNUNET_BLOCK_evaluate (GDS_block_context, |
1916 | &peer->phash)) ); | 1919 | GNUNET_BLOCK_TYPE_DHT_HELLO, |
1920 | bg, | ||
1921 | GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO, | ||
1922 | &peer->phash, | ||
1923 | NULL, 0, | ||
1924 | hello, | ||
1925 | hello_size)) ); | ||
1917 | GDS_NEIGHBOURS_handle_reply (sender, | 1926 | GDS_NEIGHBOURS_handle_reply (sender, |
1918 | GNUNET_BLOCK_TYPE_DHT_HELLO, | 1927 | GNUNET_BLOCK_TYPE_DHT_HELLO, |
1919 | GNUNET_TIME_relative_to_absolute | 1928 | GNUNET_TIME_relative_to_absolute |
@@ -1924,7 +1933,7 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender, | |||
1924 | 0, | 1933 | 0, |
1925 | NULL, | 1934 | NULL, |
1926 | hello, | 1935 | hello, |
1927 | GNUNET_HELLO_size (hello)); | 1936 | hello_size); |
1928 | } | 1937 | } |
1929 | 1938 | ||
1930 | 1939 | ||
@@ -2052,15 +2061,10 @@ handle_dht_p2p_get (void *cls, | |||
2052 | xquery); | 2061 | xquery); |
2053 | GNUNET_free (tmp); | 2062 | GNUNET_free (tmp); |
2054 | } | 2063 | } |
2055 | bg = GNUNET_BLOCK_group_create (GDS_block_context, | ||
2056 | type, | ||
2057 | get->bf_mutator, | ||
2058 | &xquery[xquery_size], | ||
2059 | reply_bf_size); | ||
2060 | eval | 2064 | eval |
2061 | = GNUNET_BLOCK_evaluate (GDS_block_context, | 2065 | = GNUNET_BLOCK_evaluate (GDS_block_context, |
2062 | type, | 2066 | type, |
2063 | bg, | 2067 | NULL, |
2064 | GNUNET_BLOCK_EO_NONE, | 2068 | GNUNET_BLOCK_EO_NONE, |
2065 | &get->key, | 2069 | &get->key, |
2066 | xquery, | 2070 | xquery, |
@@ -2071,7 +2075,6 @@ handle_dht_p2p_get (void *cls, | |||
2071 | { | 2075 | { |
2072 | /* request invalid or block type not supported */ | 2076 | /* request invalid or block type not supported */ |
2073 | GNUNET_break_op (eval == GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED); | 2077 | GNUNET_break_op (eval == GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED); |
2074 | GNUNET_BLOCK_group_destroy (bg); | ||
2075 | return; | 2078 | return; |
2076 | } | 2079 | } |
2077 | peer_bf = GNUNET_CONTAINER_bloomfilter_init (get->bloomfilter, | 2080 | peer_bf = GNUNET_CONTAINER_bloomfilter_init (get->bloomfilter, |
@@ -2080,6 +2083,11 @@ handle_dht_p2p_get (void *cls, | |||
2080 | GNUNET_break_op (GNUNET_YES == | 2083 | GNUNET_break_op (GNUNET_YES == |
2081 | GNUNET_CONTAINER_bloomfilter_test (peer_bf, | 2084 | GNUNET_CONTAINER_bloomfilter_test (peer_bf, |
2082 | &peer->phash)); | 2085 | &peer->phash)); |
2086 | bg = GNUNET_BLOCK_group_create (GDS_block_context, | ||
2087 | type, | ||
2088 | get->bf_mutator, | ||
2089 | &xquery[xquery_size], | ||
2090 | reply_bf_size); | ||
2083 | /* remember request for routing replies */ | 2091 | /* remember request for routing replies */ |
2084 | GDS_ROUTING_add (peer->id, | 2092 | GDS_ROUTING_add (peer->id, |
2085 | type, | 2093 | type, |
diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c index 0304dad87..168497440 100644 --- a/src/dht/plugin_block_dht.c +++ b/src/dht/plugin_block_dht.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2010 GNUnet e.V. | 3 | Copyright (C) 2010, 2017 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |