A cache for metadata: peer_metadata : peer_id -> (last_seen, metadata)
A cache for peer backoffs: peer_backoffs : peer_id -> (last_seen, backoff_counter)
If we fail to get metadata from a peer, we put them in the peer_backoffs cache. We can then also iterate over the cache and see which backoffs have expired (i.e. now() - last_seen > backoff_timeout)
If we succeed getting metadata (either first try or later) we put them in the peer_metadata map and emit an event.
Context
We need a
PeerStore
for 2 things:peer_metadata : peer_id -> (last_seen, metadata)
peer_backoffs : peer_id -> (last_seen, backoff_counter)
If we fail to get metadata from a peer, we put them in the
peer_backoffs
cache. We can then also iterate over the cache and see which backoffs have expired (i.e.now() - last_seen > backoff_timeout
)If we succeed getting metadata (either first try or later) we put them in the
peer_metadata
map and emit an event.