Improve eth1 logging

This commit is contained in:
Paul Hauner
2019-11-26 09:09:26 +11:00
parent 68f0e632f3
commit 81f89c054c
4 changed files with 23 additions and 4 deletions

View File

@@ -54,6 +54,11 @@ impl BlockCache {
self.blocks.is_empty()
}
/// Returns the timestamp of the earliest block in the cache (if any).
pub fn earliest_block_timestamp(&self) -> Option<u64> {
self.blocks.first().map(|block| block.timestamp)
}
/// Returns the highest block number stored.
pub fn highest_block_number(&self) -> Option<u64> {
self.blocks.last().map(|block| block.number)

View File

@@ -168,6 +168,11 @@ impl Service {
*(self.inner.block_cache.write()) = BlockCache::default();
}
/// Returns the timestamp of the earliest block in the cache (if any).
pub fn earliest_block_timestamp(&self) -> Option<u64> {
self.inner.block_cache.read().earliest_block_timestamp()
}
/// Returns the number of currently cached blocks.
pub fn block_cache_len(&self) -> usize {
self.blocks().read().len()