4 Commits

Author SHA1 Message Date
8ffdfbeb5e Merge 707b4fb709 into 796ea518bd 2025-08-27 08:34:40 +00:00
707b4fb709 chore(rpc): return types compliance 2025-08-27 10:34:34 +02:00
796ea518bd Merge pull request #47 from hl-archive-node/fix/issue-46
fix: Sort hl-node files correctly
2025-08-27 02:49:16 +09:00
dd2c925af2 fix: Sort hl-node files correctly 2025-08-26 13:47:34 -04:00
3 changed files with 33 additions and 5 deletions

View File

@ -18,7 +18,7 @@ use alloy_rpc_types::{
};
use jsonrpsee::{proc_macros::rpc, PendingSubscriptionSink, SubscriptionMessage, SubscriptionSink};
use jsonrpsee_core::{async_trait, RpcResult};
use jsonrpsee_types::ErrorObject;
use jsonrpsee_types::{error::INTERNAL_ERROR_CODE, ErrorObject};
use reth::{api::FullNodeComponents, builder::rpc::RpcContext, tasks::TaskSpawner};
use reth_primitives_traits::{BlockBody as _, SignedTransaction};
use reth_provider::{BlockIdReader, BlockReader, BlockReaderIdExt, ReceiptProvider};
@ -113,7 +113,11 @@ where
hash: B256,
) -> RpcResult<Option<Vec<RpcTransaction<Eth::NetworkTypes>>>> {
trace!(target: "rpc::eth", ?hash, "Serving eth_getEvmSystemTxsByBlockHash");
self.get_evm_system_txs_by_block_number(Some(BlockId::Hash(hash.into()))).await
match self.get_evm_system_txs_by_block_number(Some(BlockId::Hash(hash.into()))).await {
Ok(Some(txs)) => Ok(Some(txs)),
// hl-node returns none if the block is not found
_ => Ok(None),
}
}
/// Returns the system transactions for a given block number, or the latest block if no block
@ -155,7 +159,12 @@ where
.collect();
Ok(Some(system_txs))
} else {
Ok(None)
// hl-node returns an error if the block is not found
Err(ErrorObject::owned(
INTERNAL_ERROR_CODE,
format!("invalid block height: {id:?}"),
Some(()),
))
}
}
}

View File

@ -17,12 +17,12 @@ impl FileOperations {
files.extend(
subentries
.filter_map(|f| f.ok().map(|f| f.path()))
.filter(|p| TimeUtils::datetime_from_path(p).is_some()),
.filter_map(|p| TimeUtils::datetime_from_path(&p).map(|dt| (dt, p))),
);
}
}
files.sort();
Some(files)
Some(files.into_iter().map(|(_, p)| p).collect())
}
pub fn find_latest_hourly_file(root: &Path) -> Option<PathBuf> {

View File

@ -193,3 +193,22 @@ async fn test_update_last_fetch_fallback() -> eyre::Result<()> {
Ok(())
}
#[test]
fn test_hourly_files_sort() -> eyre::Result<()> {
let temp_dir = tempfile::tempdir()?;
// create 20250826/9, 20250826/14
let targets = [("20250826", "9"), ("20250826", "14")];
for (date, hour) in targets {
let hourly_file = temp_dir.path().join(HOURLY_SUBDIR).join(date).join(hour);
let parent = hourly_file.parent().unwrap();
std::fs::create_dir_all(parent)?;
std::fs::File::create(hourly_file)?;
}
let files = FileOperations::all_hourly_files(temp_dir.path()).unwrap();
let file_names: Vec<_> =
files.into_iter().map(|p| p.file_name().unwrap().to_string_lossy().into_owned()).collect();
assert_eq!(file_names, ["9", "14"]);
Ok(())
}