Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ogabrielides committed Apr 30, 2024
1 parent 01da079 commit de6b28b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
21 changes: 1 addition & 20 deletions grovedb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub mod query_result_type;
#[cfg(any(feature = "full", feature = "verify"))]
pub mod reference_path;
#[cfg(feature = "full")]
mod replication;
pub mod replication;
#[cfg(all(test, feature = "full"))]
mod tests;
#[cfg(feature = "full")]
Expand All @@ -169,7 +169,6 @@ mod versioning;
#[cfg(feature = "full")]
mod visualize;

use std::collections::BTreeSet;
#[cfg(feature = "full")]
use std::{collections::HashMap, option::Option::None, path::Path};

Expand Down Expand Up @@ -200,8 +199,6 @@ use grovedb_merk::{
tree::{combine_hash, value_hash},
BatchEntry, CryptoHash, KVIterator, Merk,
};
#[cfg(feature = "full")]
use grovedb_merk::{proofs::Op, ChunkProducer, Restorer};
use grovedb_path::SubtreePath;
#[cfg(feature = "full")]
use grovedb_storage::rocksdb_storage::PrefixedRocksDbImmediateStorageContext;
Expand All @@ -224,10 +221,6 @@ use crate::element::helpers::raw_decode;
#[cfg(any(feature = "full", feature = "verify"))]
pub use crate::error::Error;
#[cfg(feature = "full")]
pub use crate::replication::StateSyncInfo;
#[cfg(feature = "full")]
use crate::replication::SubtreesMetadata;
#[cfg(feature = "full")]
use crate::util::{root_merk_optional_tx, storage_context_optional_tx};
use crate::Error::MerkError;

Expand All @@ -251,18 +244,6 @@ pub type TransactionArg<'db, 'a> = Option<&'a Transaction<'db>>;

#[cfg(feature = "full")]
impl GroveDb {
pub fn create_state_sync_info(&self) -> StateSyncInfo {
let pending_chunks = BTreeSet::new();
let processed_prefixes = BTreeSet::new();
StateSyncInfo {
restorer: None,
processed_prefixes,
current_prefix: None,
pending_chunks,
num_processed_chunks: 0,
}
}

/// Opens a given path
pub fn open<P: AsRef<Path>>(path: P) -> Result<Self, Error> {
let db = RocksDbStorage::default_rocksdb_with_path(path)?;
Expand Down
14 changes: 13 additions & 1 deletion grovedb/src/replication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ pub fn util_split_global_chunk_id(

#[cfg(feature = "full")]
impl GroveDb {
pub fn create_state_sync_info(&self) -> StateSyncInfo {
let pending_chunks = BTreeSet::new();
let processed_prefixes = BTreeSet::new();
StateSyncInfo {
restorer: None,
processed_prefixes,
current_prefix: None,
pending_chunks,
num_processed_chunks: 0,
}
}

// Returns the discovered subtrees found recursively along with their associated
// metadata Params:
// tx: Transaction. Function returns the data by opening merks at given tx.
Expand All @@ -116,7 +128,7 @@ impl GroveDb {
&'db self,
tx: &'db Transaction,
) -> Result<SubtreesMetadata, Error> {
let mut subtrees_metadata = crate::SubtreesMetadata::new();
let mut subtrees_metadata = crate::replication::SubtreesMetadata::new();

let subtrees_root = self.find_subtrees(&SubtreePath::empty(), Some(tx)).value?;
for subtree in subtrees_root.into_iter() {
Expand Down
2 changes: 1 addition & 1 deletion tutorials/src/bin/replication.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::VecDeque;
use std::path::Path;
use grovedb::{operations::insert::InsertOptions, Element, GroveDb, PathQuery, Query, Transaction, StateSyncInfo};
use grovedb::{operations::insert::InsertOptions, Element, GroveDb, PathQuery, Query, Transaction, replication::StateSyncInfo};
use grovedb::reference_path::ReferencePathType;
use rand::{distributions::Alphanumeric, Rng, };
use grovedb::element::SumValue;
Expand Down

0 comments on commit de6b28b

Please sign in to comment.