global: snapshot

This commit is contained in:
nym21
2025-10-23 18:30:29 +02:00
parent 6cd60a064b
commit 4f1653b086
234 changed files with 758 additions and 722 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
use brk_structs::Block;
use brk_types::Block;
use crate::State;
+9 -5
View File
@@ -3,7 +3,7 @@ use std::sync::Arc;
use brk_error::Result;
use brk_reader::Reader;
use brk_rpc::Client;
use brk_structs::{BlockHash, Height};
use brk_types::{BlockHash, Height};
mod iterator;
mod range;
@@ -67,7 +67,7 @@ impl Blocks {
}
/// Iterate after hash
pub fn after(&self, hash: BlockHash) -> Result<BlockIterator> {
pub fn after(&self, hash: Option<BlockHash>) -> Result<BlockIterator> {
self.iter(BlockRange::After { hash })
}
@@ -109,10 +109,14 @@ impl Blocks {
Ok((start, end, None))
}
BlockRange::After { hash } => {
let block_info = client.get_block_header_info(&hash)?;
let start = (block_info.height + 1).into();
let start = if let Some(hash) = hash.as_ref() {
let block_info = client.get_block_header_info(hash)?;
(block_info.height + 1).into()
} else {
Height::ZERO
};
let end = client.get_last_height()?;
Ok((start, end, Some(hash)))
Ok((start, end, hash))
}
}
}
+2 -2
View File
@@ -1,9 +1,9 @@
use brk_structs::{BlockHash, Height};
use brk_types::{BlockHash, Height};
pub enum BlockRange {
Span { start: Height, end: Height },
Start { start: Height },
End { end: Height },
Last { n: u32 },
After { hash: BlockHash },
After { hash: Option<BlockHash> },
}
+1 -1
View File
@@ -2,7 +2,7 @@ use std::vec;
use brk_reader::{Reader, Receiver};
use brk_rpc::Client;
use brk_structs::{BlockHash, Height, ReadBlock};
use brk_types::{BlockHash, Height, ReadBlock};
pub enum State {
Rpc {