mirror of
https://github.com/fluencelabs/js-libp2p-secio
synced 2025-03-15 18:00:52 +00:00
Fix freeze in createExchange
This commit is contained in:
parent
9b16472930
commit
a4bd3fc838
@ -45,18 +45,36 @@ exports.createExchange = (state, callback) => {
|
|||||||
state.ephemeralKey.local
|
state.ephemeralKey.local
|
||||||
])
|
])
|
||||||
|
|
||||||
state.key.local.sign(selectionOut, (err, sig) => {
|
// CODE BELOW WORKS
|
||||||
if (err) {
|
state.key.local.sign(selectionOut).then((sig) => {
|
||||||
return callback(err)
|
log('2. exchange (promise) – corpus signed')
|
||||||
}
|
|
||||||
|
|
||||||
state.exchange.out = {
|
state.exchange.out = {
|
||||||
epubkey: state.ephemeralKey.local,
|
epubkey: state.ephemeralKey.local,
|
||||||
signature: sig
|
signature: sig
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null, pbm.Exchange.encode(state.exchange.out))
|
callback(null, pbm.Exchange.encode(state.exchange.out))
|
||||||
|
}).catch((err) => {
|
||||||
|
if (err) {
|
||||||
|
return callback(err)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// CODE BELOW HANGS
|
||||||
|
// state.key.local.sign(selectionOut, (err, sig) => {
|
||||||
|
// log('2. exchange – corpus signed, err', err, 'sig', sig)
|
||||||
|
|
||||||
|
// if (err) {
|
||||||
|
// return callback(err)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// state.exchange.out = {
|
||||||
|
// epubkey: state.ephemeralKey.local,
|
||||||
|
// signature: sig
|
||||||
|
// }
|
||||||
|
|
||||||
|
// callback(null, pbm.Exchange.encode(state.exchange.out))
|
||||||
|
// })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user