Add some basic COMPACT_FILTERS support
[dnsseed-rust] / src / datastore.rs
index 354a37d62aa5f63bd96bf5226bb814163d0da829..829fe0e1e7c7e9871b91af4da328636bc50a6e89 100644 (file)
@@ -170,12 +170,12 @@ impl SockAddr {
 }
 
 struct Nodes {
-       good_node_services: Vec<HashSet<SockAddr>>,
+       good_node_services: [HashSet<SockAddr>; 64],
        nodes_to_state: HashMap<SockAddr, Node>,
        state_next_scan: Vec<Vec<(Instant, SockAddr)>>,
 }
 struct NodesMutRef<'a> {
-       good_node_services: &'a mut Vec<HashSet<SockAddr>>,
+       good_node_services: &'a mut [HashSet<SockAddr>; 64],
        nodes_to_state: &'a mut HashMap<SockAddr, Node>,
        state_next_scan: &'a mut Vec<Vec<(Instant, SockAddr)>>,
 }
@@ -264,10 +264,7 @@ impl Store {
                                for _ in 0..AddressState::get_count() {
                                        state_vecs.push(Vec::new());
                                }
-                               let mut good_node_services = Vec::with_capacity(64);
-                               for _ in 0..64 {
-                                       good_node_services.push(HashSet::new());
-                               }
+                               let good_node_services = [HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new()];
                                Nodes {
                                        good_node_services,
                                        nodes_to_state: HashMap::new(),
@@ -489,7 +486,28 @@ impl Store {
                        let mut dns_buff = String::new();
                        {
                                let mut rng = thread_rng();
-                               for i in &[1u64, 4, 5, 8, 9, 12, 13, 1024, 1025, 1028, 1029, 1032, 1033, 1036, 1037] {
+                               for i in &[ 0b00000000001u64,
+                                           0b00000000100,
+                                           0b00000000101,
+                                           0b00000001000,
+                                           0b00000001001,
+                                           0b00000001100,
+                                           0b00000001101,
+                                           0b00001001001,
+                                           0b10000000000,
+                                           0b10000000001,
+                                           0b10000000100,
+                                           0b10000000101,
+                                           0b10000001000,
+                                           0b10000001001,
+                                           0b10000001100,
+                                           0b10000001101,
+                                           0b10001001000] {
+                               //            ^ NODE_NETWORK_LIIMTED
+                               //COMPACT_FILTERS ^   ^ NODE_BLOOM
+                               //      NODE_WITNESS ^  ^ NODE_NETWORK
+                               // We support all combos of NETWORK, NETWORK_LIMITED, BLOOM, and WITNESS
+                               // We support COMPACT_FILTERS with WITNESS and NETWORK or NETWORK_LIIMTED.
                                        let mut tor_set: Vec<Ipv6Addr> = Vec::new();
                                        let mut v6_set: Vec<Ipv6Addr> = Vec::new();
                                        let mut v4_set: Vec<Ipv4Addr> = Vec::new();