bsv_tracker/host.rs
1use crate::{CheckError, Hint, Proof, Reask, Timestamp, TxId};
2
3/// The host's proof transport. The crate declares it but never calls it.
4pub trait ProofFetcher {
5 /// The transport's own error type.
6 type Error;
7 /// Execute a scheduled re-ask, with no proof represented explicitly.
8 /// Competitor hints name the txids the host must also reconcile.
9 ///
10 /// # Errors
11 ///
12 /// The transport's own error, for the host to handle.
13 fn fetch(&mut self, txid: &str, reask: &Reask) -> Result<Option<Proof>, Self::Error>;
14}
15
16/// The host's callbacks, SSE listener, polls or other hint inputs.
17pub trait HintSource {
18 /// The source's own error type.
19 type Error;
20 /// Supply the next named observation, or none. The tracker owns no loop.
21 ///
22 /// # Errors
23 ///
24 /// The source's own error, for the host to handle.
25 fn next_hint(&mut self) -> Result<Option<(TxId, Hint)>, Self::Error>;
26}
27
28/// The host's time source. The tracker never reads a platform clock.
29pub trait Clock {
30 /// Seconds in the same time domain used for hints and age thresholds.
31 fn now(&self) -> Timestamp;
32}
33
34/// An error surface a host may use when rechecking before a spend.
35pub type SpendCheck = Result<(), CheckError>;