bitcoinocracy icon indicating copy to clipboard operation
bitcoinocracy copied to clipboard

Update bitcoin balances in the background

Open arsenische opened this issue 9 years ago • 4 comments

Currently each HTTP request with a 10% probability triggers a call to blockchain.info API to update bitcoin balances (see ApplicationController#update_bitcoin_balance), thus users sometimes need to wait few seconds more for the call to complete.

It was implemented this way because we use a free Heroku instance, but there is probably a better solution to this problem.

Bitcoin balances should be updated in the background. Can it be done for free?

arsenische avatar Sep 04 '15 06:09 arsenische

This is your major problem/feature, so yeah, this needs to be solved :)

I would suggest running your own node, then fetching each new block and matching all tx's vs your stored addresses, updating balances. This would probably be the most efficient way.

You might want to delay this by about 6 blocks to decrease the changes of reorg.

Alternatively, you could use something like chain.com's notifications on each new block (or maybe even each of your addresses) and then use their web API. At least as a temporary solution.

NxtChg avatar Sep 06 '15 09:09 NxtChg

I agree that running own node would be the best solution (it doesn't require a third party), but I doubt it can be done for free.

Chain.com's API looks good, we can subscribe to bitcoin addresses and handle the HTTP post requests for free. Thanks for the hint!

arsenische avatar Sep 06 '15 17:09 arsenische

There are other similar services, you might want to google for something like 'blockchain api". Maybe some of them would be more convenient or useful.

But if you want this project to be more than a simple toy, running your own node is pretty much the only option. And it is free.

NxtChg avatar Sep 06 '15 17:09 NxtChg

Bitcoin is free, but servers are not.

This project is non-commercial, so I'd prefer to stay on the Heroku's free plan (unless Bitcoinocracy becomes useful for many people).

If I bought a server for each idea I had, I would have run out of money long ago :)

arsenische avatar Sep 06 '15 18:09 arsenische