mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Compare commits
2 Commits
40c0b24e6a
...
7d90b07386
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d90b07386 | |||
| 738567894a |
@ -29,6 +29,7 @@ use tokio::sync::Mutex;
|
||||
use tracing::{debug, info};
|
||||
|
||||
use crate::serialized::{BlockAndReceipts, EvmBlock};
|
||||
use crate::share_blocks::ShareBlocks;
|
||||
use crate::spot_meta::erc20_contract_to_spot_token;
|
||||
|
||||
/// Poll interval when tailing an *open* hourly file.
|
||||
@ -41,6 +42,7 @@ pub(crate) struct BlockIngest {
|
||||
pub local_ingest_dir: Option<PathBuf>,
|
||||
pub local_blocks_cache: Arc<Mutex<BTreeMap<u64, BlockAndReceipts>>>, // height → block
|
||||
pub precompiles_cache: PrecompilesCache,
|
||||
pub hlfs: Option<ShareBlocks>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
||||
@ -54,12 +54,12 @@ impl ShareBlocks {
|
||||
}
|
||||
});
|
||||
|
||||
let _autodetect = spawn_autodetect(network, host, args.share_blocks_port, args.archive_dir.clone());
|
||||
let _autodetect =
|
||||
spawn_autodetect(network, host, args.share_blocks_port, args.archive_dir.clone());
|
||||
|
||||
info!(%bind, dir=%args.archive_dir.display(), "hlfs: enabled (reth peers)");
|
||||
Ok(Self { _server, _autodetect })
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn spawn_autodetect<Net>(
|
||||
|
||||
@ -194,7 +194,20 @@ fn find_max_number_file(root: &Path) -> Result<u64> {
|
||||
}
|
||||
|
||||
let mut best = Some(0);
|
||||
walk(root, &mut best)?;
|
||||
let top: PathBuf = fs::read_dir(root)?
|
||||
.filter_map(|e| e.ok())
|
||||
.filter(|e| e.file_type().map(|t| t.is_dir()).unwrap_or(false))
|
||||
.filter_map(|e| {
|
||||
let name = e.file_name();
|
||||
let s = name.to_str()?;
|
||||
let n: u64 = s.parse().ok()?;
|
||||
Some((n, e.path()))
|
||||
})
|
||||
.max_by_key(|(n, _)| *n)
|
||||
.map(|(_, p)| p)
|
||||
.ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, "no numeric top-level dirs"))?;
|
||||
|
||||
walk(&top, &mut best)?;
|
||||
Ok(best.expect("cannot find block files"))
|
||||
}
|
||||
|
||||
@ -327,10 +340,7 @@ impl Backfiller {
|
||||
}
|
||||
}
|
||||
}
|
||||
pub async fn fetch_if_missing(
|
||||
&mut self,
|
||||
number: u64,
|
||||
) -> Result<Option<u64>, HlfsError> {
|
||||
pub async fn fetch_if_missing(&mut self, number: u64) -> Result<Option<u64>, HlfsError> {
|
||||
let rr_index = number as usize;
|
||||
let n = number.saturating_sub(1); // 0 -> 0, others -> number-1
|
||||
let f = (n / 1_000_000) * 1_000_000;
|
||||
|
||||
Reference in New Issue
Block a user