Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Support Promise and callbacks for async functions #66

Closed
s1na opened this issue Jan 10, 2019 · 1 comment · Fixed by #107
Closed

Support Promise and callbacks for async functions #66

s1na opened this issue Jan 10, 2019 · 1 comment · Fixed by #107

Comments

@s1na
Copy link
Contributor

s1na commented Jan 10, 2019

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
Copy link

todofixthis commented Mar 23, 2020

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())
))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants