bitview: reorg part 8

This commit is contained in:
nym21
2025-09-29 14:17:49 +02:00
parent 7407c032e5
commit 62d4b35c93
39 changed files with 319 additions and 3937 deletions
+6 -4
View File
@@ -9,6 +9,7 @@ use std::{
path::PathBuf,
sync::Arc,
thread,
time::Duration,
};
use bitcoin::{block::Header, consensus::Decodable};
@@ -29,8 +30,6 @@ use any_block::*;
pub use xor_bytes::*;
pub use xor_index::*;
pub const NUMBER_OF_UNSAFE_BLOCKS: usize = 100;
const MAGIC_BYTES: [u8; 4] = [249, 190, 180, 217];
const BOUND_CAP: usize = 50;
@@ -79,7 +78,7 @@ impl Parser {
pub fn parse(&self, start: Option<Height>, end: Option<Height>) -> Receiver<ParsedBlock> {
let rpc = self.rpc;
let (send_bytes, recv_bytes) = bounded(BOUND_CAP);
let (send_bytes, recv_bytes) = bounded(BOUND_CAP / 2);
let (send_block, recv_block) = bounded(BOUND_CAP);
let (send_ordered, recv_ordered) = bounded(BOUND_CAP);
@@ -183,10 +182,13 @@ impl Parser {
recv_bytes.iter().try_for_each(|tuple| {
bulk.push(tuple);
if bulk.len() < BOUND_CAP {
if bulk.len() < BOUND_CAP / 2 {
return ControlFlow::Continue(());
}
while send_block.len() >= bulk.len() {
thread::sleep(Duration::from_micros(100));
}
drain_and_send(&mut bulk)
})?;