correct sync memory usage calculation (#2385)
This commit is contained in:
parent
6b541bc774
commit
f4dfbada0a
@ -19,7 +19,7 @@ use rlp::*;
|
|||||||
use network::NetworkError;
|
use network::NetworkError;
|
||||||
use ethcore::header::{ Header as BlockHeader};
|
use ethcore::header::{ Header as BlockHeader};
|
||||||
|
|
||||||
known_heap_size!(0, HeaderId, SyncBlock);
|
known_heap_size!(0, HeaderId);
|
||||||
|
|
||||||
/// Block data with optional body.
|
/// Block data with optional body.
|
||||||
struct SyncBlock {
|
struct SyncBlock {
|
||||||
@ -27,6 +27,12 @@ struct SyncBlock {
|
|||||||
body: Option<Bytes>,
|
body: Option<Bytes>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl HeapSizeOf for SyncBlock {
|
||||||
|
fn heap_size_of_children(&self) -> usize {
|
||||||
|
self.header.heap_size_of_children() + self.body.heap_size_of_children()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Used to identify header by transactions and uncles hashes
|
/// Used to identify header by transactions and uncles hashes
|
||||||
#[derive(Eq, PartialEq, Hash)]
|
#[derive(Eq, PartialEq, Hash)]
|
||||||
struct HeaderId {
|
struct HeaderId {
|
||||||
@ -219,10 +225,14 @@ impl BlockCollection {
|
|||||||
self.blocks.contains_key(hash)
|
self.blocks.contains_key(hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return heap size.
|
/// Return used heap size.
|
||||||
pub fn heap_size(&self) -> usize {
|
pub fn heap_size(&self) -> usize {
|
||||||
//TODO: other collections
|
self.heads.heap_size_of_children()
|
||||||
self.blocks.heap_size_of_children()
|
+ self.blocks.heap_size_of_children()
|
||||||
|
+ self.parents.heap_size_of_children()
|
||||||
|
+ self.header_ids.heap_size_of_children()
|
||||||
|
+ self.downloading_headers.heap_size_of_children()
|
||||||
|
+ self.downloading_bodies.heap_size_of_children()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if given block hash is marked as being downloaded.
|
/// Check if given block hash is marked as being downloaded.
|
||||||
|
Loading…
Reference in New Issue
Block a user