Support Promise and callbacks for async functions
s1na opened this issue · 1 comments
s1na commented
Now that the library has been ported to ES6 (#44), a further step would be to support Promise (as well as callbacks for backward compatibility), to enable async/await
syntax for consumers of the library.
todofixthis commented
Here is an example of a workaround that I am using, in this case computing the tx root for a block:
const util = require('util')
const trie = new Trie()
const put = util.promisify(trie.put.bind(trie))
await Promise.all(transactionsRaw.map((t, i) =>
put(rlp.encode(i), new Transaction(t).serialize())
))