-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: choose peers from the connected pool, instead of dialing unconnected peers #2096
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,11 +198,6 @@ export class BaseProtocolSDK implements IBaseProtocolSDK { | |
this.log.info(`Finding and adding ${numPeers} new peers`); | ||
try { | ||
const additionalPeers = await this.findAdditionalPeers(numPeers); | ||
const dials = additionalPeers.map((peer) => | ||
this.connectionManager.attemptDial(peer.id) | ||
); | ||
|
||
await Promise.all(dials); | ||
|
||
const updatedPeers = [...this.peers, ...additionalPeers]; | ||
this.updatePeers(updatedPeers); | ||
|
@@ -227,10 +222,17 @@ export class BaseProtocolSDK implements IBaseProtocolSDK { | |
private async findAdditionalPeers(numPeers: number): Promise<Peer[]> { | ||
this.log.info(`Finding ${numPeers} additional peers`); | ||
try { | ||
let newPeers = await this.core.allPeers(); | ||
let newPeers = await this.core.getPeers({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you try this in practice, e.g dogfooding app? |
||
maxBootstrapPeers: 0, | ||
numPeers: 0 | ||
}); | ||
|
||
if (newPeers.length === 0) { | ||
this.log.warn("No new peers found."); | ||
this.log.warn("No new peers found, trying with bootstrap peers"); | ||
newPeers = await this.core.getPeers({ | ||
maxBootstrapPeers: numPeers, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't previous line return all bootstrap peers already? |
||
numPeers: 0 | ||
}); | ||
} | ||
|
||
newPeers = newPeers | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it removed?