-
Notifications
You must be signed in to change notification settings - Fork 88
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
Better peer sorting and updated initial diallng #2427
Conversation
@@ -517,7 +517,7 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI | |||
agent: this.socksProxyAgent, | |||
localAddress: this.libp2pService.createLibp2pAddress(onionAddress, peerId.toString()), | |||
targetPort: this.ports.libp2pHiddenService, | |||
peers: peers ?? [], | |||
peers: peers ? peers.slice(1) : [], |
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.
This is to avoid the self-dialing we normally see.
): string[] => { | ||
peersAddresses = filterValidAddresses(peersAddresses) | ||
const currentlyConnected = [...stats].filter(peer => peer.connectionTime === 0) |
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.
When a peer connects we set the connectionTime
to zero so peers with that value present should be currently connected (or connected the last time we were online). This means for invitation links the peers are more likely to be online and when we go offline, if we went offline recently, we're more likely to try connecting to online peers (this becomes less likely the longer a user is offline but that's true for connection time filtering, too).
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.
Should we be saving who we were last connected to, whenever we shut down, or periodically?
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.
That is something I also considered, you can give libp2p a datastore so it can persist the peer data it had on shutdown.
private processItem: (arg: T) => Promise<any> | ||
private readonly logger = Logger(ProcessInChunksService.name) | ||
constructor() { | ||
super() | ||
} | ||
|
||
public init(data: T[], processItem: (arg: T) => Promise<any>, chunkSize: number = DEFAULT_CHUNK_SIZE) { | ||
this.data = data | ||
this.logger(`Initializing process-in-chunks.service with peers ${JSON.stringify(data, null, 2)}`) |
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.
We don't have to address this now, but eventually we want to sanitize addresses like onion addresses or peerid's from the logs.
): string[] => { | ||
peersAddresses = filterValidAddresses(peersAddresses) | ||
const currentlyConnected = [...stats].filter(peer => peer.connectionTime === 0) |
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.
Should we be saving who we were last connected to, whenever we shut down, or periodically?
@@ -121,7 +122,7 @@ afterEach(async () => { | |||
}) | |||
|
|||
describe('Connections manager', () => { | |||
it('saves peer stats when peer has been disconnected', async () => { | |||
it.only('saves peer stats when peer has been disconnected', async () => { |
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.
Is this only
here in purpose?
* Better peer sorting and updated initial diallng * Update tests
Pull Request Checklist
(Optional) Mobile checklist
Please ensure you completed the following checks if you did any changes to the mobile package: