Skip to content

Commit

Permalink
suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ogabrielides committed Jan 13, 2025
1 parent c00ecbd commit 420f84c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
7 changes: 7 additions & 0 deletions packages/rs-drive-abci/src/abci/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pub struct StateSyncAbciConfig {
pub snapshots_enabled: bool,

/// Path to checkpoints
#[serde(default = "StateSyncAbciConfig::default_checkpoints_path")]
pub checkpoints_path: PathBuf,

/// Frequency of snapshot creation (in blocks)
Expand Down Expand Up @@ -113,4 +114,10 @@ impl StateSyncAbciConfig {
max_num_snapshots: 10,
}
}

fn default_checkpoints_path() -> PathBuf {
std::env::var("CHECKPOINTS_PATH")
.map(PathBuf::from)
.unwrap_or_else(|_| PathBuf::from("/var/lib/dash-platform/data/checkpoints"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,6 @@ where
)
})?;
if incorrect_hashes.len() > 0 {
for element in incorrect_hashes.keys() {
let subtree_path: Vec<&[u8]> = element.iter().map(|vec| vec.as_slice()).collect();
let path: &[&[u8]] = &subtree_path;
let prefix = RocksDbStorage::build_prefix(path.into()).unwrap();
println!(
"[state_sync] incorrect hash in prefix:{:?}",
hex::encode(prefix)
);
}
Err(AbciError::StateSyncInternalError(format!(
"apply_snapshot_chunk grovedb verification failed with {} incorrect hashes",
incorrect_hashes.len()
Expand Down
6 changes: 2 additions & 4 deletions packages/rs-drive-abci/src/abci/handler/list_snapshots.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::path::Path;
use crate::abci::app::{PlatformApplication, SnapshotManagerApplication};
use crate::abci::handler::error::error_into_exception;
use crate::abci::AbciError;
Expand Down Expand Up @@ -37,10 +38,7 @@ where
}
};
let checkpoint_exists = |s: &Snapshot| -> bool {
match GroveDb::open(&s.path) {
Ok(_) => true,
Err(_) => false,
}
Path::new(&s.path).exists()
};

response.snapshots = snapshots
Expand Down
4 changes: 2 additions & 2 deletions packages/rs-drive-abci/src/platform_types/snapshot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl SnapshotManager {
pub fn get_snapshots(&self, grove: &GroveDb) -> Result<Vec<Snapshot>, Error> {
let data = grove
.get_aux(SNAPSHOT_KEY, None)
.unwrap()
.value
.map_err(|e| Error::Drive(GroveDB(e)))?;

match data {
Expand Down Expand Up @@ -208,7 +208,7 @@ impl SnapshotManager {
.map_err(|e| Error::Drive(Drive(DriveError::Snapshot(e.to_string()))))?;
grove
.put_aux(SNAPSHOT_KEY, data.as_slice(), None, None)
.unwrap()
.value
.map_err(|e| Error::Drive(GroveDB(e)))?;
Ok(())
}
Expand Down

0 comments on commit 420f84c

Please sign in to comment.