From 696dc05dda17afaa6633db6c12e626907a671a8a Mon Sep 17 00:00:00 2001 From: Anton Gavrilov Date: Tue, 8 Jan 2019 01:31:26 +0100 Subject: [PATCH] Remove caching for node connections (#10143) --- ethcore/node-filter/src/lib.rs | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/ethcore/node-filter/src/lib.rs b/ethcore/node-filter/src/lib.rs index de7f78cb0..816bb84a8 100644 --- a/ethcore/node-filter/src/lib.rs +++ b/ethcore/node-filter/src/lib.rs @@ -39,9 +39,6 @@ extern crate log; use std::sync::Weak; -use lru_cache::LruCache; -use parking_lot::Mutex; - use ethcore::client::{BlockChainClient, BlockId}; use ethereum_types::{H256, Address}; use ethabi::FunctionOutputDecoder; @@ -50,13 +47,10 @@ use devp2p::NodeId; use_contract!(peer_set, "res/peer_set.json"); -const MAX_CACHE_SIZE: usize = 4096; - /// Connection filter that uses a contract to manage permissions. pub struct NodeFilter { client: Weak, contract_address: Address, - permission_cache: Mutex>, } impl NodeFilter { @@ -65,7 +59,6 @@ impl NodeFilter { NodeFilter { client, contract_address, - permission_cache: Mutex::new(LruCache::new(MAX_CACHE_SIZE)), } } } @@ -77,18 +70,6 @@ impl ConnectionFilter for NodeFilter { None => return false, }; - let block_hash = match client.block_hash(BlockId::Latest) { - Some(block_hash) => block_hash, - None => return false, - }; - - let key = (block_hash, *connecting_id); - - let mut cache = self.permission_cache.lock(); - if let Some(res) = cache.get_mut(&key) { - return *res; - } - let address = self.contract_address; let own_low = H256::from_slice(&own_id[0..32]); let own_high = H256::from_slice(&own_id[32..64]); @@ -103,7 +84,6 @@ impl ConnectionFilter for NodeFilter { false }); - cache.insert(key, allowed); allowed } }