Skip to content

Commit

Permalink
Move proof module to be a child of merkle
Browse files Browse the repository at this point in the history
  • Loading branch information
richardpringle committed Nov 14, 2023
1 parent 1531e9f commit 79a3385
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 26 deletions.
6 changes: 4 additions & 2 deletions firewood/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ pub use crate::{
};
use crate::{
file,
merkle::{Merkle, MerkleError, Node, TrieHash, TRIE_HASH_LEN},
proof::{HashKey, Proof, ProofError},
merkle::{
proof::{HashKey, Proof, ProofError},
Merkle, MerkleError, Node, TrieHash, TRIE_HASH_LEN,
},
storage::{
buffer::{DiskBuffer, DiskBufferRequester},
CachedSpace, MemStoreR, SpaceWrite, StoreConfig, StoreDelta, StoreRevMut, StoreRevShared,
Expand Down
8 changes: 5 additions & 3 deletions firewood/src/db/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ use super::{
DbHeader, DbInner, DbRev, DbRevInner, SharedStore, Store, Universe, MERKLE_META_SPACE,
MERKLE_PAYLOAD_SPACE, ROOT_HASH_SPACE,
};
use crate::proof::{HashKey, Proof};
use crate::shale::CachedStore;
use crate::{
merkle::{TrieHash, TRIE_HASH_LEN},
merkle::{
proof::{HashKey, Proof},
TrieHash, TRIE_HASH_LEN,
},
shale::CachedStore,
storage::{buffer::BufferWrite, AshRecord, StoreRevMut},
v2::api::{self, KeyType, ValueType},
};
Expand Down
1 change: 0 additions & 1 deletion firewood/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ pub mod db;
pub(crate) mod file;
pub mod merkle;
pub mod merkle_util;
pub mod proof;
pub mod storage;

pub mod config;
Expand Down
9 changes: 7 additions & 2 deletions firewood/src/merkle.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
// Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE.md for licensing terms.

use crate::shale::{self, disk_address::DiskAddress, ObjWriteError, ShaleError, ShaleStore};
use crate::{nibbles::Nibbles, proof::Proof};
use crate::{
nibbles::Nibbles,
shale::{self, disk_address::DiskAddress, ObjWriteError, ShaleError, ShaleStore},
};
use sha3::Digest;
use std::{cmp::Ordering, collections::HashMap, io::Write, iter::once, sync::OnceLock};
use thiserror::Error;

mod node;
pub mod proof;
mod trie_hash;

pub use node::{BranchNode, Data, ExtNode, LeafNode, Node, NodeType, PartialPath};
pub use trie_hash::{TrieHash, TRIE_HASH_LEN};

use proof::Proof;

type ObjRef<'a> = shale::ObjRef<'a, Node>;
type ParentRefs<'a> = Vec<(ObjRef<'a>, u8)>;
type ParentAddresses = Vec<(DiskAddress, u8)>;
Expand Down
File renamed without changes.
14 changes: 8 additions & 6 deletions firewood/src/merkle_util.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE.md for licensing terms.

use crate::shale::{
self, cached::DynamicMem, compact::CompactSpace, disk_address::DiskAddress, CachedStore,
ShaleStore, StoredView,
};
use crate::{
merkle::{Merkle, Node, Ref, RefMut, TrieHash},
proof::{Proof, ProofError},
merkle::{
proof::{Proof, ProofError},
Merkle, Node, Ref, RefMut, TrieHash,
},
shale::{
self, cached::DynamicMem, compact::CompactSpace, disk_address::DiskAddress, CachedStore,
ShaleStore, StoredView,
},
};
use std::{num::NonZeroUsize, sync::Arc};
use thiserror::Error;
Expand Down
2 changes: 1 addition & 1 deletion firewood/src/v2/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{fmt::Debug, sync::Arc};

use async_trait::async_trait;

use crate::proof::{HashKey, Proof};
use crate::merkle::proof::{HashKey, Proof};

/// A `KeyType` is something that can be xcast to a u8 reference,
/// and can be sent and shared across threads. References with
Expand Down
2 changes: 1 addition & 1 deletion firewood/src/v2/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use async_trait::async_trait;

use crate::{
db::DbError,
proof::HashKey,
merkle::proof::HashKey,
v2::api::{self, Batch, KeyType, ValueType},
};

Expand Down
8 changes: 5 additions & 3 deletions firewood/src/v2/emptydb.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE.md for licensing terms.

use super::api::{Batch, Db, DbView, Error, KeyType, RangeProof, ValueType};
use super::propose::{Proposal, ProposalBase};
use crate::proof::{HashKey, Proof};
use super::{
api::{Batch, Db, DbView, Error, KeyType, RangeProof, ValueType},
propose::{Proposal, ProposalBase},
};
use crate::merkle::proof::{HashKey, Proof};
use async_trait::async_trait;
use std::sync::Arc;

Expand Down
11 changes: 4 additions & 7 deletions firewood/src/v2/propose.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
// Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE.md for licensing terms.

use std::{collections::BTreeMap, fmt::Debug, sync::Arc};

use async_trait::async_trait;

use super::api::{KeyType, ValueType};
use crate::{
proof::{HashKey, Proof},
merkle::proof::{HashKey, Proof},
v2::api,
};

use super::api::{KeyType, ValueType};
use async_trait::async_trait;
use std::{collections::BTreeMap, fmt::Debug, sync::Arc};

#[derive(Clone, Debug)]
pub(crate) enum KeyOp<V: ValueType> {
Expand Down

0 comments on commit 79a3385

Please sign in to comment.