Keep Peer Caching + Resource Verification.

This commit is contained in:
mr
2026-02-09 13:28:00 +01:00
parent 1c0b2b4312
commit fa914958b6
14 changed files with 221 additions and 133 deletions

View File

@@ -48,12 +48,15 @@ func NewIndexerService(h host.Host, ps *pubsub.PubSub, maxNode int) *IndexerServ
}
f := func(ctx context.Context, evt common.TopicNodeActivityPub, _ string) {
ix.mu.Lock()
if evt.NodeActivity == pp.OFFLINE {
delete(ix.DisposedPeers, evt.Disposer.ID)
}
if evt.NodeActivity == pp.ONLINE {
ix.DisposedPeers[evt.Disposer.ID] = &evt
if pid, err := peer.Decode(evt.PeerID); err == nil {
if evt.NodeActivity == pp.OFFLINE.EnumIndex() {
delete(ix.DisposedPeers, pid)
}
if evt.NodeActivity == pp.ONLINE.EnumIndex() {
ix.DisposedPeers[pid] = &evt
}
}
ix.mu.Unlock()
}
ix.SubscribeToNodeActivity(ix.PS, &f) // now we subscribe to a long run topic named node-activity, to relay message.