Move reth-primitives::fs module to fs-utils crate (#8286)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Serge Radinovich
2024-05-17 20:31:31 +12:00
committed by GitHub
parent b177c29f93
commit 9441d984ae
39 changed files with 142 additions and 65 deletions

View File

@ -15,6 +15,7 @@ workspace = true
# reth
reth-eth-wire.workspace = true
reth-primitives.workspace = true
reth-fs-util.workspace = true
reth-provider.workspace = true
reth-tasks.workspace = true
revm.workspace = true

View File

@ -11,10 +11,11 @@ use futures_util::{
future::{BoxFuture, Fuse, FusedFuture},
FutureExt, Stream, StreamExt,
};
use reth_fs_util::FsPathError;
use reth_primitives::{
fs::FsPathError, Address, BlockHash, BlockNumber, BlockNumberOrTag,
FromRecoveredPooledTransaction, IntoRecoveredTransaction, PooledTransactionsElementEcRecovered,
TransactionSigned, TryFromRecoveredTransaction,
Address, BlockHash, BlockNumber, BlockNumberOrTag, FromRecoveredPooledTransaction,
IntoRecoveredTransaction, PooledTransactionsElementEcRecovered, TransactionSigned,
TryFromRecoveredTransaction,
};
use reth_provider::{
BlockReaderIdExt, BundleStateWithReceipts, CanonStateNotification, ChainSpecProvider,
@ -578,7 +579,7 @@ where
}
debug!(target: "txpool", txs_file =?file_path, "Check local persistent storage for saved transactions");
let data = reth_primitives::fs::read(file_path)?;
let data = reth_fs_util::read(file_path)?;
if data.is_empty() {
return Ok(())
@ -598,7 +599,7 @@ where
let outcome = pool.add_transactions(crate::TransactionOrigin::Local, pool_transactions).await;
info!(target: "txpool", txs_file =?file_path, num_txs=%outcome.len(), "Successfully reinserted local transactions from file");
reth_primitives::fs::remove_file(file_path)?;
reth_fs_util::remove_file(file_path)?;
Ok(())
}
@ -623,7 +624,7 @@ where
info!(target: "txpool", txs_file =?file_path, num_txs=%num_txs, "Saving current local transactions");
let parent_dir = file_path.parent().map(std::fs::create_dir_all).transpose();
match parent_dir.map(|_| reth_primitives::fs::write(file_path, buf)) {
match parent_dir.map(|_| reth_fs_util::write(file_path, buf)) {
Ok(_) => {
info!(target: "txpool", txs_file=?file_path, "Wrote local transactions to file");
}
@ -680,7 +681,8 @@ mod tests {
blobstore::InMemoryBlobStore, validate::EthTransactionValidatorBuilder,
CoinbaseTipOrdering, EthPooledTransaction, Pool, PoolTransaction, TransactionOrigin,
};
use reth_primitives::{fs, hex, PooledTransactionsElement, MAINNET, U256};
use reth_fs_util as fs;
use reth_primitives::{hex, PooledTransactionsElement, MAINNET, U256};
use reth_provider::test_utils::{ExtendedAccount, MockEthProvider};
use reth_tasks::TaskManager;