mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 02:49:55 +00:00
only consider top level highest dir name on archive node file root; also added back hlfs to blockingest struct
This commit is contained in:
@ -29,6 +29,7 @@ use tokio::sync::Mutex;
|
|||||||
use tracing::{debug, info};
|
use tracing::{debug, info};
|
||||||
|
|
||||||
use crate::serialized::{BlockAndReceipts, EvmBlock};
|
use crate::serialized::{BlockAndReceipts, EvmBlock};
|
||||||
|
use crate::share_blocks::ShareBlocks;
|
||||||
use crate::spot_meta::erc20_contract_to_spot_token;
|
use crate::spot_meta::erc20_contract_to_spot_token;
|
||||||
|
|
||||||
/// Poll interval when tailing an *open* hourly file.
|
/// Poll interval when tailing an *open* hourly file.
|
||||||
@ -41,6 +42,7 @@ pub(crate) struct BlockIngest {
|
|||||||
pub local_ingest_dir: Option<PathBuf>,
|
pub local_ingest_dir: Option<PathBuf>,
|
||||||
pub local_blocks_cache: Arc<Mutex<BTreeMap<u64, BlockAndReceipts>>>, // height → block
|
pub local_blocks_cache: Arc<Mutex<BTreeMap<u64, BlockAndReceipts>>>, // height → block
|
||||||
pub precompiles_cache: PrecompilesCache,
|
pub precompiles_cache: PrecompilesCache,
|
||||||
|
pub hlfs: Option<ShareBlocks>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[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)");
|
info!(%bind, dir=%args.archive_dir.display(), "hlfs: enabled (reth peers)");
|
||||||
Ok(Self { _server, _autodetect })
|
Ok(Self { _server, _autodetect })
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn_autodetect<Net>(
|
fn spawn_autodetect<Net>(
|
||||||
|
|||||||
@ -194,7 +194,20 @@ fn find_max_number_file(root: &Path) -> Result<u64> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut best = Some(0);
|
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"))
|
Ok(best.expect("cannot find block files"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,10 +340,7 @@ impl Backfiller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub async fn fetch_if_missing(
|
pub async fn fetch_if_missing(&mut self, number: u64) -> Result<Option<u64>, HlfsError> {
|
||||||
&mut self,
|
|
||||||
number: u64,
|
|
||||||
) -> Result<Option<u64>, HlfsError> {
|
|
||||||
let rr_index = number as usize;
|
let rr_index = number as usize;
|
||||||
let n = number.saturating_sub(1); // 0 -> 0, others -> number-1
|
let n = number.saturating_sub(1); // 0 -> 0, others -> number-1
|
||||||
let f = (n / 1_000_000) * 1_000_000;
|
let f = (n / 1_000_000) * 1_000_000;
|
||||||
|
|||||||
Reference in New Issue
Block a user