Skip to main content

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    fn fetch(&mut self, txid: &str, reask: &Reask) -> Result<Option<Proof>, Self::Error>;
10}
11
12/// The host's callbacks, SSE listener, polls or other hint inputs.
13pub trait HintSource {
14    /// The source's own error type.
15    type Error;
16    /// Supply the next named observation, or none. The tracker owns no loop.
17    fn next_hint(&mut self) -> Result<Option<(TxId, Hint)>, Self::Error>;
18}
19
20/// The host's time source. The tracker never reads a platform clock.
21pub trait Clock {
22    /// Seconds in the same time domain used for hints and age thresholds.
23    fn now(&self) -> Timestamp;
24}
25
26/// An error surface a host may use when rechecking before a spend.
27pub type SpendCheck = Result<(), CheckError>;