Keep Peer Caching + Resource Verification.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user