Backports to beta (#2068)
* Fix several RPCs (#1926) * Fix up pending receipts details. * Add support for additional params and registry over RPC. * Fix tests. * Add test, additional fix. Fixes #1932. * Fix up tests. * Fix test. * Fix test. * DB WAL size limit (#1935) * Limit WAL size * Check pruning by db modification date (#1924) * Cache address hash (#1943) * ECIES without MAC (#1948) * Use random IV for ECIES AES * ECIES encrypt/decrypt for a single message * Derive IV from shared secret * Apply settings to column families * fixed #1933 (#1979) * Fixed neighbours collection (#1996) * dapps-hosts configuration * Disabled counter check * always process trie death row on commit, add more tracing * fixed transaction addresses mapping, fixes #1971 * simplified iterator * v1.3.1 * v1.3.1
This commit is contained in:
@@ -59,7 +59,7 @@ pub struct BucketEntry {
|
||||
pub timeout: Option<u64>,
|
||||
}
|
||||
|
||||
struct NodeBucket {
|
||||
pub struct NodeBucket {
|
||||
nodes: VecDeque<BucketEntry>, //sorted by last active
|
||||
}
|
||||
|
||||
@@ -281,12 +281,12 @@ impl Discovery {
|
||||
if count == BUCKET_SIZE {
|
||||
// delete the most distant element
|
||||
let remove = {
|
||||
let (_, last) = found.iter_mut().next_back().unwrap();
|
||||
let (key, last) = found.iter_mut().next_back().unwrap();
|
||||
last.pop();
|
||||
last.is_empty()
|
||||
if last.is_empty() { Some(key.clone()) } else { None }
|
||||
};
|
||||
if remove {
|
||||
found.remove(&distance);
|
||||
if let Some(remove) = remove {
|
||||
found.remove(&remove);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -605,6 +605,21 @@ mod tests {
|
||||
assert!(removed > 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_nearest_saturated() {
|
||||
use super::*;
|
||||
let mut buckets: Vec<_> = (0..256).map(|_| NodeBucket::new()).collect();
|
||||
let ep = NodeEndpoint { address: SocketAddr::from_str("127.0.0.1:40447").unwrap(), udp_port: 40447 };
|
||||
for _ in 0..(16 + 10) {
|
||||
buckets[0].nodes.push_back(BucketEntry {
|
||||
address: NodeEntry { id: NodeId::new(), endpoint: ep.clone() },
|
||||
timeout: None
|
||||
});
|
||||
}
|
||||
let nearest = Discovery::nearest_node_entries(&NodeId::new(), &buckets);
|
||||
assert_eq!(nearest.len(), 16)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn packets() {
|
||||
let key = KeyPair::create().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user