Skip to content

Commit

Permalink
Devp2p: increase network resilience for the case that no initial conf…
Browse files Browse the repository at this point in the history
…irmation is possible
  • Loading branch information
holgerd77 committed Oct 27, 2023
1 parent 1f90acd commit df49bac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/devp2p/src/dpt/dpt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class DPT {

getClosestPeers(id: Uint8Array) {
let peers = this._kbucket.closest(id)
if (this._onlyConfirmed) {
if (this._onlyConfirmed && this._confirmedPeers.size > 0) {
peers = peers.filter((peer) =>
this._confirmedPeers.has(bytesToUnprefixedHex(peer.id as Uint8Array)) ? true : false
)
Expand Down Expand Up @@ -221,7 +221,7 @@ export class DPT {
// to decide on subdivided execution
const selector = bytesToInt((peer.id as Uint8Array).subarray(0, 1)) % 10
let confirmed = true
if (this._onlyConfirmed) {
if (this._onlyConfirmed && this._confirmedPeers.size > 0) {
const id = bytesToUnprefixedHex(peer.id as Uint8Array)
if (!this._confirmedPeers.has(id)) {
confirmed = false
Expand Down

0 comments on commit df49bac

Please sign in to comment.