|
1 | 1 | use crate::{ |
2 | 2 | marshal::{ |
| 3 | + ancestry::BlockProvider, |
3 | 4 | coding::{ |
4 | 5 | shards, |
5 | 6 | types::{CodedBlock, CodedBlockCfg, StoredCodedBlock}, |
6 | 7 | }, |
7 | | - core::{Buffer, Variant}, |
| 8 | + core::{Buffer, DigestFallback, Mailbox, Variant}, |
8 | 9 | }, |
9 | 10 | simplex::types::Context, |
10 | 11 | types::{coding::Commitment, Round}, |
11 | 12 | CertifiableBlock, |
12 | 13 | }; |
13 | 14 | use commonware_codec::Read; |
14 | 15 | use commonware_coding::Scheme as CodingScheme; |
15 | | -use commonware_cryptography::{Committable, Digestible, Hasher, PublicKey}; |
| 16 | +use commonware_cryptography::{certificate::Scheme, Committable, Digestible, Hasher, PublicKey}; |
16 | 17 | use commonware_p2p::Recipients; |
17 | 18 | use commonware_utils::channel::oneshot; |
18 | 19 |
|
@@ -113,3 +114,21 @@ where |
113 | 114 | self.proposed(round, block); |
114 | 115 | } |
115 | 116 | } |
| 117 | + |
| 118 | +impl<S, B, C, H, P> BlockProvider for Mailbox<S, Coding<B, C, H, P>> |
| 119 | +where |
| 120 | + S: Scheme, |
| 121 | + B: CertifiableBlock<Context = Context<Commitment, P>>, |
| 122 | + C: CodingScheme, |
| 123 | + H: Hasher, |
| 124 | + P: PublicKey, |
| 125 | +{ |
| 126 | + type Block = B; |
| 127 | + |
| 128 | + async fn subscribe(self, digest: B::Digest) -> Option<Self::Block> { |
| 129 | + self.subscribe_by_digest(digest, DigestFallback::Wait) |
| 130 | + .await |
| 131 | + .ok() |
| 132 | + .map(<Coding<B, C, H, P> as Variant>::into_inner) |
| 133 | + } |
| 134 | +} |
0 commit comments