parser: fixed hanging + global: snapshot

This commit is contained in:
nym21
2025-02-23 21:53:39 +01:00
parent 19cf34f9d4
commit 8acbcc548c
30 changed files with 372 additions and 383 deletions
+25
View File
@@ -0,0 +1,25 @@
use bitcoin::{Block, consensus::Decodable, io::Cursor};
use crate::{XORBytes, XORIndex};
pub enum BlockState {
Raw(Vec<u8>),
Decoded(Block),
}
impl BlockState {
pub fn decode(&mut self, xor_i: &mut XORIndex, xor_bytes: &XORBytes) {
let bytes = match self {
BlockState::Raw(bytes) => bytes,
_ => unreachable!(),
};
xor_i.bytes(bytes.as_mut_slice(), xor_bytes);
let mut cursor = Cursor::new(bytes);
let block = Block::consensus_decode(&mut cursor).unwrap();
*self = BlockState::Decoded(block);
}
}