Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions ethcore/node-filter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<BlockChainClient>,
contract_address: Address,
permission_cache: Mutex<LruCache<(H256, NodeId), bool>>,
}

impl NodeFilter {
Expand All @@ -65,7 +59,6 @@ impl NodeFilter {
NodeFilter {
client,
contract_address,
permission_cache: Mutex::new(LruCache::new(MAX_CACHE_SIZE)),
}
}
}
Expand All @@ -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]);
Expand All @@ -103,7 +84,6 @@ impl ConnectionFilter for NodeFilter {
false
});

cache.insert(key, allowed);
allowed
}
}
Expand Down