chore: split db abstraction into new crate (#8594)

This commit is contained in:
Oliver
2024-06-04 23:45:57 +02:00
committed by GitHub
parent a8095740fc
commit 51a28f22da
183 changed files with 825 additions and 755 deletions

View File

@ -15,6 +15,7 @@ workspace = true
# reth
reth-primitives.workspace = true
reth-db.workspace = true
reth-db-api.workspace = true
reth-errors.workspace = true
reth-provider.workspace = true
reth-tokio-util.workspace = true

View File

@ -1,6 +1,6 @@
use crate::{segments::SegmentSet, Pruner};
use reth_config::PruneConfig;
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_primitives::{FinishedExExHeight, PruneModes, MAINNET};
use reth_provider::ProviderFactory;
use std::time::Duration;

View File

@ -5,7 +5,7 @@ use crate::{
segments::{PruneInput, Segment},
Metrics, PrunerError, PrunerEvent,
};
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_primitives::{
BlockNumber, FinishedExExHeight, PruneLimiter, PruneMode, PruneProgress, PrunePurpose,
PruneSegment, StaticFileSegment,

View File

@ -4,7 +4,8 @@ use crate::{
},
PrunerError,
};
use reth_db::{database::Database, models::ShardedKey, tables};
use reth_db::tables;
use reth_db_api::{database::Database, models::ShardedKey};
use reth_primitives::{PruneInterruptReason, PruneMode, PruneProgress, PruneSegment};
use reth_provider::DatabaseProviderRW;
use tracing::{instrument, trace};

View File

@ -5,10 +5,10 @@ use crate::{
PrunerError,
};
use itertools::Itertools;
use reth_db::{
use reth_db::tables;
use reth_db_api::{
cursor::{DbCursorRO, RangeWalker},
database::Database,
tables,
transaction::DbTxMut,
};
@ -188,7 +188,8 @@ where
#[cfg(test)]
mod tests {
use assert_matches::assert_matches;
use reth_db::{tables, transaction::DbTx};
use reth_db::tables;
use reth_db_api::transaction::DbTx;
use reth_primitives::{
BlockNumber, PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneProgress,
PruneSegment, B256, U256,

View File

@ -1,10 +1,11 @@
use reth_db::{
use reth_db::BlockNumberList;
use reth_db_api::{
cursor::{DbCursorRO, DbCursorRW},
database::Database,
models::ShardedKey,
table::Table,
transaction::DbTxMut,
BlockNumberList, DatabaseError,
DatabaseError,
};
use reth_primitives::BlockNumber;
use reth_provider::DatabaseProviderRW;

View File

@ -14,7 +14,7 @@ pub use account_history::AccountHistory;
pub use headers::Headers;
pub use receipts::Receipts;
pub use receipts_by_logs::ReceiptsByLogs;
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_primitives::{
BlockNumber, PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneProgress,
PruneSegment, TxNumber,

View File

@ -2,7 +2,8 @@ use crate::{
segments::{PruneInput, PruneOutput, PruneOutputCheckpoint, Segment},
PrunerError,
};
use reth_db::{database::Database, tables};
use reth_db::tables;
use reth_db_api::database::Database;
use reth_primitives::{PruneCheckpoint, PruneMode, PruneProgress, PruneSegment};
use reth_provider::{
errors::provider::ProviderResult, DatabaseProviderRW, PruneCheckpointWriter,

View File

@ -2,7 +2,8 @@ use crate::{
segments::{PruneInput, PruneOutput, Segment},
PrunerError,
};
use reth_db::{database::Database, tables};
use reth_db::tables;
use reth_db_api::database::Database;
use reth_primitives::{
PruneCheckpoint, PruneMode, PruneProgress, PrunePurpose, PruneSegment, ReceiptsLogPruneConfig,
MINIMUM_PRUNING_DISTANCE,
@ -216,7 +217,8 @@ impl<DB: Database> Segment<DB> for ReceiptsByLogs {
mod tests {
use crate::segments::{receipts_by_logs::ReceiptsByLogs, PruneInput, Segment};
use assert_matches::assert_matches;
use reth_db::{cursor::DbCursorRO, tables, transaction::DbTx};
use reth_db::tables;
use reth_db_api::{cursor::DbCursorRO, transaction::DbTx};
use reth_primitives::{PruneLimiter, PruneMode, PruneSegment, ReceiptsLogPruneConfig, B256};
use reth_provider::{PruneCheckpointReader, TransactionsProvider};
use reth_stages::test_utils::{StorageKind, TestStageDB};

View File

@ -2,7 +2,8 @@ use crate::{
segments::{PruneInput, PruneOutput, PruneOutputCheckpoint, Segment},
PrunerError,
};
use reth_db::{database::Database, tables};
use reth_db::tables;
use reth_db_api::database::Database;
use reth_primitives::{PruneMode, PruneProgress, PruneSegment};
use reth_provider::{DatabaseProviderRW, TransactionsProvider};
use tracing::{instrument, trace};

View File

@ -2,7 +2,7 @@ use crate::segments::{
AccountHistory, Receipts, ReceiptsByLogs, Segment, SenderRecovery, StorageHistory,
TransactionLookup,
};
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_primitives::PruneModes;
/// Collection of [Segment]. Thread-safe, allocated on the heap.

View File

@ -4,10 +4,10 @@ use crate::{
},
PrunerError,
};
use reth_db::{
use reth_db::tables;
use reth_db_api::{
database::Database,
models::{storage_sharded_key::StorageShardedKey, BlockNumberAddress},
tables,
};
use reth_primitives::{PruneInterruptReason, PruneMode, PruneProgress, PruneSegment};
use reth_provider::DatabaseProviderRW;

View File

@ -3,7 +3,8 @@ use crate::{
PrunerError,
};
use rayon::prelude::*;
use reth_db::{database::Database, tables};
use reth_db::tables;
use reth_db_api::database::Database;
use reth_primitives::{PruneMode, PruneProgress, PruneSegment};
use reth_provider::{DatabaseProviderRW, TransactionsProvider};
use tracing::{instrument, trace};

View File

@ -2,7 +2,8 @@ use crate::{
segments::{PruneInput, PruneOutput, PruneOutputCheckpoint, Segment},
PrunerError,
};
use reth_db::{database::Database, tables};
use reth_db::tables;
use reth_db_api::database::Database;
use reth_primitives::{PruneMode, PruneProgress, PruneSegment};
use reth_provider::{DatabaseProviderRW, TransactionsProvider};
use tracing::{instrument, trace};