Remove local providers (#268)

* add remove provider method

* remove failed providers

* bumping dht to latest master
This commit is contained in:
Dmitriy Ryajov 2022-10-05 10:01:21 -06:00 committed by GitHub
parent 58f0439f37
commit 106b04340a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 3 deletions

View File

@ -152,8 +152,14 @@ proc discoveryTaskLoop(b: DiscoveryEngine) {.async.} =
peers = await request
trace "Discovered peers", peers = peers.len
checkFutures(
await allFinished(peers.mapIt( b.network.dialPeer(it.data))))
let
dialed = await allFinished(
peers.mapIt( b.network.dialPeer(it.data) ))
for i, f in dialed:
if f.failed:
await b.discovery.removeProvider(peers[i].data.peerId)
finally:
b.inFlightDiscReqs.del(cid)
codex_inflight_discovery.set(b.inFlightAdvReqs.len.int64)

View File

@ -137,6 +137,13 @@ method provide*(d: Discovery, host: ca.Address) {.async, base.} =
if nodes.len > 0:
trace "Provided to nodes", nodes = nodes.len
method removeProvider*(d: Discovery, peerId: PeerId): Future[void] =
## Remove provider from providers table
##
trace "Removing provider", peerId
d.protocol.removeProvidersLocal(peerId)
proc start*(d: Discovery) {.async.} =
d.protocol.updateRecord(
d.localInfo.signedPeerRecord.some)

@ -1 +1 @@
Subproject commit 4b9fa0356e6cefbbbcedcf21a914cda575229774
Subproject commit 08928e57d82736ab9524010a3bd59a707f2e0769