mirror of https://codeberg.org/pzp/pzp-sync.git
improve logic when an RPC connect is detected
This commit is contained in:
parent
af5ac3435d
commit
403fcefc3a
|
@ -47,19 +47,20 @@ module.exports = {
|
||||||
if (!iamClient) return
|
if (!iamClient) return
|
||||||
const local = toPull.duplex(createStream(rpc.id, true))
|
const local = toPull.duplex(createStream(rpc.id, true))
|
||||||
|
|
||||||
|
let abort
|
||||||
const remote = rpc.tangleSync.connect((networkError) => {
|
const remote = rpc.tangleSync.connect((networkError) => {
|
||||||
if (networkError && getSeverity(networkError) >= 3) {
|
if (networkError && getSeverity(networkError) >= 3) {
|
||||||
if (isMuxrpcMissingError(networkError, 'tangleSync', 'connect')) {
|
if (isMuxrpcMissingError(networkError, 'tangleSync', 'connect')) {
|
||||||
console.warn(`peer ${rpc.id} does not support sync connect`)
|
debug('peer %s does not support tangleSync', rpc.id)
|
||||||
// } else if (isReconnectedError(networkError)) { // TODO: bring back
|
// } else if (isReconnectedError(networkError)) { // TODO: bring back
|
||||||
// Do nothing, this is a harmless error
|
// Do nothing, this is a harmless error
|
||||||
} else {
|
} else {
|
||||||
console.error(`rpc.tangleSync.connect exception:`, networkError)
|
console.error(`rpc.tangleSync.connect exception:`, networkError)
|
||||||
}
|
}
|
||||||
|
abort?.(true, () => {})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
abort = pull(local, remote, local)
|
||||||
pull(local, remote, local)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function connect() {
|
function connect() {
|
||||||
|
|
Loading…
Reference in New Issue