mirror of
https://github.com/fluencelabs/js-libp2p-secio
synced 2025-03-15 01:40:51 +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.key.local.sign(selectionOut, (err, sig) => {
|
||||
if (err) {
|
||||
return callback(err)
|
||||
}
|
||||
|
||||
// CODE BELOW WORKS
|
||||
state.key.local.sign(selectionOut).then((sig) => {
|
||||
log('2. exchange (promise) – corpus signed')
|
||||
state.exchange.out = {
|
||||
epubkey: state.ephemeralKey.local,
|
||||
signature: sig
|
||||
}
|
||||
|
||||
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