mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-23 05:51:37 +00:00
feat: coalescing dial support (#518)
* docs: fix spelling in api * fix: dont create peerstore twice * feat: add support for dial coalescing * doc(fix): add setPeerValue to API TOC * docs: add more jsdocs to dialer * chore: remove old comment * fix: ensure connections are closed * fix: registrar.getConnections returns first open conn * fix: directly set the closed status * chore: remove unneeded log * refactor: peerStore.put takes an options object
This commit is contained in:
@ -98,7 +98,6 @@ class Upgrader {
|
||||
} catch (err) {
|
||||
log.error('Failed to upgrade inbound connection', err)
|
||||
await maConn.close(err)
|
||||
// TODO: We shouldn't throw here, as there isn't anything to catch the failure
|
||||
throw err
|
||||
}
|
||||
|
||||
@ -248,9 +247,11 @@ class Upgrader {
|
||||
pipe(muxedConnection, muxer, muxedConnection)
|
||||
|
||||
maConn.timeline.upgraded = Date.now()
|
||||
const timelineProxy = new Proxy(maConn.timeline, {
|
||||
const _timeline = maConn.timeline
|
||||
maConn.timeline = new Proxy(_timeline, {
|
||||
set: (...args) => {
|
||||
if (args[1] === 'close' && args[2]) {
|
||||
if (args[1] === 'close' && args[2] && !_timeline.close) {
|
||||
connection.stat.status = 'closed'
|
||||
this.onConnectionEnd(connection)
|
||||
}
|
||||
|
||||
@ -266,7 +267,7 @@ class Upgrader {
|
||||
remotePeer: remotePeer,
|
||||
stat: {
|
||||
direction,
|
||||
timeline: timelineProxy,
|
||||
timeline: maConn.timeline,
|
||||
multiplexer: Muxer.multicodec,
|
||||
encryption: cryptoProtocol
|
||||
},
|
||||
|
Reference in New Issue
Block a user