Skip to content

Commit

Permalink
Improve log structure
Browse files Browse the repository at this point in the history
  • Loading branch information
slowli committed Jun 14, 2024
1 parent a7ff971 commit 444c748
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 29 deletions.
6 changes: 2 additions & 4 deletions core/lib/state/src/catchup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,10 @@ impl AsyncCatchupTask {
/// # Errors
///
/// Propagates RocksDB and Postgres errors.
#[tracing::instrument(name = "catch_up", skip_all, fields(target_l1_batch = ?self.to_l1_batch_number))]
pub async fn run(self, stop_receiver: watch::Receiver<bool>) -> anyhow::Result<()> {
let started_at = Instant::now();
tracing::debug!(
"Catching up RocksDB asynchronously to L1 batch #{:?}",
self.to_l1_batch_number
);
tracing::info!("Catching up RocksDB asynchronously");

let mut rocksdb_builder = RocksdbStorage::builder_with_options(
self.state_keeper_db_path.as_ref(),
Expand Down
42 changes: 17 additions & 25 deletions core/node/state_keeper/src/state_keeper_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,23 @@ pub struct AsyncRocksdbCache {
}

impl AsyncRocksdbCache {
async fn access_storage_inner(
pub fn new(
pool: ConnectionPool<Core>,
state_keeper_db_path: String,
state_keeper_db_options: RocksdbStorageOptions,
) -> (Self, AsyncCatchupTask) {
let (task, rocksdb_cell) = AsyncCatchupTask::new(pool.clone(), state_keeper_db_path);
(
Self { pool, rocksdb_cell },
task.with_db_options(state_keeper_db_options),
)
}
}

#[async_trait]
impl ReadStorageFactory for AsyncRocksdbCache {
#[tracing::instrument(skip(self, stop_receiver))]
async fn access_storage(
&self,
stop_receiver: &watch::Receiver<bool>,
l1_batch_number: L1BatchNumber,
Expand Down Expand Up @@ -63,28 +79,4 @@ impl AsyncRocksdbCache {
))
}
}

pub fn new(
pool: ConnectionPool<Core>,
state_keeper_db_path: String,
state_keeper_db_options: RocksdbStorageOptions,
) -> (Self, AsyncCatchupTask) {
let (task, rocksdb_cell) = AsyncCatchupTask::new(pool.clone(), state_keeper_db_path);
(
Self { pool, rocksdb_cell },
task.with_db_options(state_keeper_db_options),
)
}
}

#[async_trait]
impl ReadStorageFactory for AsyncRocksdbCache {
async fn access_storage(
&self,
stop_receiver: &watch::Receiver<bool>,
l1_batch_number: L1BatchNumber,
) -> anyhow::Result<Option<PgOrRocksdbStorage<'_>>> {
self.access_storage_inner(stop_receiver, l1_batch_number)
.await
}
}

0 comments on commit 444c748

Please sign in to comment.