Fix freeze in createExchange

This commit is contained in:
folex 2019-12-24 07:03:29 +03:00 committed by GitHub
parent 9b16472930
commit a4bd3fc838
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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))
// })
})
}