Skip to content

Commit de6b28b

Browse files
committed
refactor
1 parent 01da079 commit de6b28b

File tree

3 files changed

+15
-22
lines changed

3 files changed

+15
-22
lines changed

grovedb/src/lib.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub mod query_result_type;
160160
#[cfg(any(feature = "full", feature = "verify"))]
161161
pub mod reference_path;
162162
#[cfg(feature = "full")]
163-
mod replication;
163+
pub mod replication;
164164
#[cfg(all(test, feature = "full"))]
165165
mod tests;
166166
#[cfg(feature = "full")]
@@ -169,7 +169,6 @@ mod versioning;
169169
#[cfg(feature = "full")]
170170
mod visualize;
171171

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

@@ -200,8 +199,6 @@ use grovedb_merk::{
200199
tree::{combine_hash, value_hash},
201200
BatchEntry, CryptoHash, KVIterator, Merk,
202201
};
203-
#[cfg(feature = "full")]
204-
use grovedb_merk::{proofs::Op, ChunkProducer, Restorer};
205202
use grovedb_path::SubtreePath;
206203
#[cfg(feature = "full")]
207204
use grovedb_storage::rocksdb_storage::PrefixedRocksDbImmediateStorageContext;
@@ -224,10 +221,6 @@ use crate::element::helpers::raw_decode;
224221
#[cfg(any(feature = "full", feature = "verify"))]
225222
pub use crate::error::Error;
226223
#[cfg(feature = "full")]
227-
pub use crate::replication::StateSyncInfo;
228-
#[cfg(feature = "full")]
229-
use crate::replication::SubtreesMetadata;
230-
#[cfg(feature = "full")]
231224
use crate::util::{root_merk_optional_tx, storage_context_optional_tx};
232225
use crate::Error::MerkError;
233226

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

252245
#[cfg(feature = "full")]
253246
impl GroveDb {
254-
pub fn create_state_sync_info(&self) -> StateSyncInfo {
255-
let pending_chunks = BTreeSet::new();
256-
let processed_prefixes = BTreeSet::new();
257-
StateSyncInfo {
258-
restorer: None,
259-
processed_prefixes,
260-
current_prefix: None,
261-
pending_chunks,
262-
num_processed_chunks: 0,
263-
}
264-
}
265-
266247
/// Opens a given path
267248
pub fn open<P: AsRef<Path>>(path: P) -> Result<Self, Error> {
268249
let db = RocksDbStorage::default_rocksdb_with_path(path)?;

grovedb/src/replication.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,18 @@ pub fn util_split_global_chunk_id(
107107

108108
#[cfg(feature = "full")]
109109
impl GroveDb {
110+
pub fn create_state_sync_info(&self) -> StateSyncInfo {
111+
let pending_chunks = BTreeSet::new();
112+
let processed_prefixes = BTreeSet::new();
113+
StateSyncInfo {
114+
restorer: None,
115+
processed_prefixes,
116+
current_prefix: None,
117+
pending_chunks,
118+
num_processed_chunks: 0,
119+
}
120+
}
121+
110122
// Returns the discovered subtrees found recursively along with their associated
111123
// metadata Params:
112124
// tx: Transaction. Function returns the data by opening merks at given tx.
@@ -116,7 +128,7 @@ impl GroveDb {
116128
&'db self,
117129
tx: &'db Transaction,
118130
) -> Result<SubtreesMetadata, Error> {
119-
let mut subtrees_metadata = crate::SubtreesMetadata::new();
131+
let mut subtrees_metadata = crate::replication::SubtreesMetadata::new();
120132

121133
let subtrees_root = self.find_subtrees(&SubtreePath::empty(), Some(tx)).value?;
122134
for subtree in subtrees_root.into_iter() {

tutorials/src/bin/replication.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::collections::VecDeque;
22
use std::path::Path;
3-
use grovedb::{operations::insert::InsertOptions, Element, GroveDb, PathQuery, Query, Transaction, StateSyncInfo};
3+
use grovedb::{operations::insert::InsertOptions, Element, GroveDb, PathQuery, Query, Transaction, replication::StateSyncInfo};
44
use grovedb::reference_path::ReferencePathType;
55
use rand::{distributions::Alphanumeric, Rng, };
66
use grovedb::element::SumValue;

0 commit comments

Comments
 (0)