Proper light client informant and more verification of imported headers (#5897)

* do more validation of imported headers in light client

* generalize informant with traits

* informant implementation for light client

* make comment into TODO

* fix broken test

* disable full checking of headers in light client in sync tests
This commit is contained in:
Robert Habermeier
2017-07-10 13:21:11 +02:00
committed by Arkadiy Paronyan
parent f0a6b5d401
commit 67c1f71b6e
8 changed files with 374 additions and 101 deletions

View File

@@ -26,7 +26,7 @@ use ethcore::receipt::Receipt;
use stats::Corpus;
use time::{SteadyTime, Duration};
use util::{U256, H256};
use util::{U256, H256, HeapSizeOf};
use util::cache::MemoryLruCache;
/// Configuration for how much data to cache.
@@ -153,6 +153,22 @@ impl Cache {
pub fn set_gas_price_corpus(&mut self, corpus: Corpus<U256>) {
self.corpus = Some((corpus, SteadyTime::now()))
}
/// Get the memory used.
pub fn mem_used(&self) -> usize {
self.heap_size_of_children()
}
}
impl HeapSizeOf for Cache {
fn heap_size_of_children(&self) -> usize {
self.headers.current_size()
+ self.canon_hashes.current_size()
+ self.bodies.current_size()
+ self.receipts.current_size()
+ self.chain_score.current_size()
// TODO: + corpus
}
}
#[cfg(test)]