Closed divagant-martian closed 1 year ago
From the questions to solve before storing this:
n
useful peers for the document. Where useful is defined as: A peer that has produced a successful sync event for the doc. I believe this is an appropriate approximation since those are peers with whom a future sync is more likely.
This encapsulates nicely many concepts:
peer_id
(peer id bytes, since this seems to be abstracted in sync), or both their peer id and peer data. Haven't finished looking into the code but I'm not sure the peer data reaches sync since it would be mostly irrelevant.From the mem store this is a simple LRU cache, for the fs store I still need to think thoroughly how to store this to capture the idea of "last n recently useful peers". Pointers welcome
Could someone confirm if this would go in the instance store? maybe @Frando ?
I think I agree to what you outlined above!
to 1: Yup, I think this makes sense. Maybe I would, in addition to that, always store the peers that were provided directly (in what currently is doc.start_sync
or via doc.join(ticket)
). And mark, per peer, whether its PeerKind::Discovered
or PeerKind::UserProvided
.
to 2: I'd say we should only store the PeerId
s per document, because we store the address info already in the MagicEndpoint
, right?
For storage: I'd think we would need to add methods in to the iroh_sync::store::Store
traits. Maybe store_peer(namespace_id, peer_id, peer_kind, last_sync_timestamp)
and get_peers(namespace_id) -> Self::PeerIterator
or something like that. The LRU would be handled in the store then. We'd have to add the capacity as a constructor argument then likely.
Finally understood how to store this, that aside, I would suggest we wait to add explicit peers until we answer some questions about this:
Going to continue for now with the found peers and see how it goes
Questions to solve: