Skip to content

Commit 25b548c

Browse files
committed
feat: add config for archive
1 parent 73d51d6 commit 25b548c

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

cli/src/cli.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,9 @@ impl Context{
271271
}
272272

273273
pub fn open_primary_store_conn(&self) -> Result<TapeStore> {
274-
Ok(tape_network::store::primary()?)
274+
let rocksdb_config = self.config.storage.rocksdb.as_ref()
275+
.ok_or_else(|| anyhow::anyhow!("RocksDB config not found"))?;
276+
Ok(tape_network::store::primary(&rocksdb_config.primary_path)?)
275277
}
276278

277279
pub fn open_secondary_store_conn_mine(&self) -> Result<TapeStore> {

cli/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ async fn run_tape_cli() -> Result<()> {
8787
Commands::Web { .. } |
8888
Commands::Archive { .. } |
8989
Commands::Mine { .. } => {
90-
TapeStore::try_init_store()?;
90+
let rocksdb_config = context.config.storage.rocksdb.as_ref()
91+
.ok_or_else(|| anyhow::anyhow!("RocksDB config not found"))?;
92+
TapeStore::try_init_store(&rocksdb_config.primary_path)?;
9193
network::handle_network_commands(cli, context).await?;
9294
}
9395

network/src/store/helpers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use super::{TapeStore, StoreError, consts::*};
22
use std::{env, sync::Arc};
33

4-
pub fn primary() -> Result<TapeStore, StoreError> {
4+
pub fn primary(tape_store_primary_db: &str) -> Result<TapeStore, StoreError> {
55
let current_dir = env::current_dir().map_err(StoreError::IoError)?;
6-
let db_primary = current_dir.join(TAPE_STORE_PRIMARY_DB);
6+
let db_primary = current_dir.join(tape_store_primary_db);
77
std::fs::create_dir_all(&db_primary).map_err(StoreError::IoError)?;
88
TapeStore::new(&db_primary)
99
}

network/src/store/store.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ impl TapeStore {
2525
Ok(Self { db })
2626
}
2727

28-
pub fn try_init_store() -> Result<(), StoreError> {
29-
if let Ok(_store) = super::helpers::primary() {
28+
pub fn try_init_store(tape_store_primary_db: &str) -> Result<(), StoreError> {
29+
if let Ok(_store) = super::helpers::primary(tape_store_primary_db) {
3030
log::debug!("Primary store initialized successfully");
3131
}
3232
Ok(())
@@ -74,4 +74,3 @@ impl Drop for TapeStore {
7474
// RocksDB handles cleanup automatically
7575
}
7676
}
77-

0 commit comments

Comments
 (0)