Skip to content

Commit 3f54493

Browse files
implement Resolver for poofs
1 parent f98eb0c commit 3f54493

2 files changed

Lines changed: 10 additions & 24 deletions

File tree

examples/sync/src/net/resolver.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,6 @@ where
232232
Op::Cfg: IsUnit,
233233
D: Digest,
234234
{
235-
type Family = mmr::Family;
236-
type Digest = D;
237-
type Error = crate::Error;
238-
239235
async fn current_target(
240236
&self,
241237
) -> Result<CurrentTarget<Self::Family, Self::Digest>, Self::Error> {

storage/src/qmdb/current/sync/mod.rs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,15 @@
2929
//! let mut last_accepted = None;
3030
//! let (accepted_tx, mut accepted_rx) = commonware_utils::channel::mpsc::channel(16);
3131
//!
32+
//! // `is_forward` is application policy, usually based on consensus metadata
33+
//! // (height, round, view, certificate sequence) associated with each root.
34+
//! // Roots are hashes and do not have a natural ordering on their own.
35+
//!
3236
//! // Consensus task: insert roots that the chain has made canonical.
3337
//! loop {
3438
//! let trusted_root = consensus_client.canonical_root_at_tip().await?;
3539
//! if let Some(target) = matcher.insert_trusted_root(trusted_root) {
40+
//! // Join succeeded: this trusted root already had a resolver target cached.
3641
//! if is_forward(&last_accepted, &target) {
3742
//! last_accepted = Some(target.clone());
3843
//! accepted_tx.clone().send(target).await?;
@@ -44,6 +49,7 @@
4449
//! loop {
4550
//! let target = resolver.current_target().await?;
4651
//! if let Some(target) = matcher.insert_candidate_target(target) {
52+
//! // Join succeeded: this target's root was already trusted by consensus.
4753
//! if is_forward(&last_accepted, &target) {
4854
//! last_accepted = Some(target.clone());
4955
//! accepted_tx.clone().send(target).await?;
@@ -161,14 +167,10 @@ pub(crate) mod tests;
161167
/// describe the same database state. Callers that learn trusted canonical roots from another source
162168
/// can cache these targets and use [`TargetMatcher`] to find a target whose root has been trusted
163169
/// before passing it to [`sync`].
164-
pub trait CurrentResolver: Send + Sync + Clone + 'static {
165-
/// Merkle family used by the database.
166-
type Family: Graftable;
167-
/// Root digest type.
168-
type Digest: Digest;
169-
/// Error type returned by the resolver.
170-
type Error: std::error::Error + Send + 'static;
171-
170+
pub trait CurrentResolver: qmdb_sync::Resolver
171+
where
172+
Self::Family: Graftable,
173+
{
172174
/// Fetch the latest full authenticated [`Target`].
173175
#[allow(clippy::type_complexity)]
174176
fn current_target(
@@ -1013,10 +1015,6 @@ macro_rules! impl_current_current_resolver {
10131015
S: Strategy,
10141016
$($($where_extra)+)?
10151017
{
1016-
type Family = F;
1017-
type Digest = H::Digest;
1018-
type Error = qmdb::Error<F>;
1019-
10201018
async fn current_target(&self) -> Result<Target<F, H::Digest>, Self::Error> {
10211019
let hasher = qmdb::hasher::<H>();
10221020
let witness = self.ops_root_witness(&hasher).await?;
@@ -1048,10 +1046,6 @@ macro_rules! impl_current_current_resolver {
10481046
S: Strategy,
10491047
$($($where_extra)+)?
10501048
{
1051-
type Family = F;
1052-
type Digest = H::Digest;
1053-
type Error = qmdb::Error<F>;
1054-
10551049
async fn current_target(&self) -> Result<Target<F, H::Digest>, Self::Error> {
10561050
let db = self.read().await;
10571051
let hasher = qmdb::hasher::<H>();
@@ -1084,10 +1078,6 @@ macro_rules! impl_current_current_resolver {
10841078
S: Strategy,
10851079
$($($where_extra)+)?
10861080
{
1087-
type Family = F;
1088-
type Digest = H::Digest;
1089-
type Error = qmdb::Error<F>;
1090-
10911081
async fn current_target(&self) -> Result<Target<F, H::Digest>, Self::Error> {
10921082
let guard = self.read().await;
10931083
let db = guard.as_ref()

0 commit comments

Comments
 (0)