1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Peer synchronization bookkeeping. Coverage is a local claim about which
//! peer listings were fully admitted; full-block scans remain the audit.
use crate::{
Error,
engine::Engine,
model::{ChainPoint, Omission},
};
impl Engine {
/// Record that `peer` (its PeerId string) listed every placement in
/// selected [from, to] and each listed placement was admitted, already
/// held, or answered Missing (listed-only).
/// `generation` is the one observed before fetching; a reorg since is Stale.
/// admit_record keeps multipart children even in Pruned mode, so synced
/// components stay until cache maintenance evicts them.
pub fn record_peer_coverage(
&self,
peer: &str,
from: u64,
to: u64,
generation: u64,
) -> Result<(), Error> {
self.archive()?
.record_peer_coverage(peer, from, to, generation)
}
/// First height after the peer's contiguous coverage from app start.
pub fn peer_cursor(&self, peer: &str) -> Result<u64, Error> {
self.archive()?.peer_cursor(peer)
}
pub fn peer_synced_through(&self) -> Result<Option<ChainPoint>, Error> {
self.archive()?.peer_synced_through()
}
pub fn omitting_peers(&self) -> Result<Vec<String>, Error> {
self.archive()?.omitting_peers()
}
pub fn peer_omissions(&self) -> Result<Vec<Omission>, Error> {
self.archive()?.peer_omissions()
}
/// The `limit` highest selected omissions, ascending; bounded in SQL.
pub fn peer_omissions_latest(&self, limit: u32) -> Result<Vec<Omission>, Error> {
self.archive()?.peer_omissions_latest(limit)
}
/// Chain peers the source holds now; 0 without a source (offline).
pub fn chain_peers(&self) -> Result<u64, Error> {
match &self.source {
Some(source) => source.chain_peers(),
None => Ok(0),
}
}
}