anchor provider trait
This commit is contained in:
parent
0d98b13e2f
commit
f995fda937
|
@ -0,0 +1,17 @@
|
|||
use hash::H256;
|
||||
use bytes::Bytes;
|
||||
use {EpochTag, RegularTreeState};
|
||||
|
||||
pub trait AnchorProvider {
|
||||
fn tree_bytes_at(&self, root: &H256) -> Option<Bytes>;
|
||||
|
||||
fn tree_at(&self, root: &H256) -> Option<RegularTreeState> {
|
||||
self.tree_bytes_at(root)
|
||||
.map(
|
||||
|bytes| serialization::Reader::new(&bytes[..])
|
||||
.read::<RegularTreeState>()
|
||||
.expect("Corrupted database: wrong tree state format!")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -25,6 +25,7 @@ mod transaction_meta;
|
|||
mod transaction_provider;
|
||||
mod nullifier;
|
||||
mod tree_state;
|
||||
mod anchors;
|
||||
|
||||
pub use primitives::{hash, bytes};
|
||||
|
||||
|
@ -41,6 +42,7 @@ pub use transaction_meta::TransactionMeta;
|
|||
pub use transaction_provider::{TransactionProvider, TransactionOutputProvider, TransactionMetaProvider};
|
||||
pub use nullifier::{Nullifier, NullifierTracker};
|
||||
pub use tree_state::{TreeState, H32 as H32TreeDim, Dim as TreeDim, RegularTreeState};
|
||||
pub use anchors::AnchorProvider;
|
||||
|
||||
/// Epoch tag.
|
||||
///
|
||||
|
|
Loading…
Reference in New Issue