termcoin icon indicating copy to clipboard operation
termcoin copied to clipboard

Suggestion: use async library

Open askmike opened this issue 12 years ago • 2 comments

First off: awesome project!

I couldn't help but notice that some functions have a lot of nested callbacks. Maybe it would be an idea to abstract the nesting out via an async library like async. This way you could separate the logic more and use optimizations like parallelizing batches of queries to bitcoind.

askmike avatar Jan 18 '14 11:01 askmike

I was going to write a really long reply to this a while ago, but the short answer is: I want to use as few dependencies as possible. When people see a bitcoin wallet (especially a brand new one like termcoin), they want to know their coins are safe. The termcoin code is very easy to skim through, and it only has one dependency (blessed, which has 0 dependencies). This kind of discussion will inevitably bring up the whole "trusting trust" thing (that it's impossible to trust any code you did not physically write, etc.), but I think it's probably better to live pragmatically in terms of security, and try to stay secure regardless. So, I'm going to try to keep termcoin as "small" as possible.

As for async itself, it's a great library, but I find it easy enough to write my own async control flow functions (serial and parallel loop functions are, what, maybe 3-4 lines each).

However, you're definitely right about parallelizing stuff like getProgress. I will do that, and should have done it from the beginning. embarrassed

If I really find myself in a rut with regards to async stuff, I'll consider using async. I'll leave this open until I parallelize the functions that need to be.

chjj avatar Feb 21 '14 03:02 chjj

Also, thanks for the kind words. Glad you like it. :)

chjj avatar Feb 21 '14 03:02 chjj