Skip to content

Commit

Permalink
network.addBootNode: Check for pong before follup requests (#695)
Browse files Browse the repository at this point in the history
* network/addBootNode: only sendFindNodes if PONG received

* network/addBootNode: ask for nodes in non-empty buckets
  • Loading branch information
ScottyPoi authored Dec 18, 2024
1 parent 5e475e2 commit a6a25c3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/portalnetwork/src/networks/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -823,11 +823,13 @@ export abstract class BaseNetwork extends EventEmitter {
// Disregard attempts to add oneself as a bootnode
return
}
await this.sendPing(enr)
for (let x = 239; x < 256; x++) {
// Ask for nodes in all log2distances 239 - 256
if (this.routingTable.valuesOfDistance(x).length === 0) {
await this.sendFindNodes(enr, [x])
const pong = await this.sendPing(enr)
if (pong !== undefined) {
for (let x = 239; x < 256; x++) {
// Ask for nodes in all log2distances 239 - 256
if (this.routingTable.valuesOfDistance(x).length < 16 ) {
await this.sendFindNodes(enr, [x])
}
}
}
}
Expand Down

0 comments on commit a6a25c3

Please sign in to comment.