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