5

For example, running bitcoin-cli getbalance <address> on an arbitrary, watch-only address takes around 6-7 seconds for a response. Is there any way to improve the response time?

How do API services like Blockchain.info return balance details almost instantaneously? Each API call to Blockchain.info takes less than half a second for a balance request. Is there a way for me to do that with bitcoind?

  • Are you using bitcoind on a vps? – Rutger Versteegden Dec 3 '17 at 17:13
  • @RutgerVersteegden no, i'm not using a VPS – user66764 Dec 3 '17 at 18:44
3

For example, running bitcoin-cli getbalance <address> on an arbitrary, watch-only address takes around 6-7 seconds for a response. Is there any way to improve this?

Besides the fact that this is not how getbalance works (you don't call it on an address), getbalance is slow here because it must go through the list of transactions for the addresses in your wallet and sum their outputs to get the balance. If your wallet is very large and has lots of transactions or you are running bitcoind on low powered hardware, this could take a long time.

How do API services like Blockchain return balance details almost instantaneously? Each API call to Blockchain takes less than half a second for a balance request. Is there a way for me to do that?

Those API services have several large servers hosting their databases. Their databases are massive and index everything in the blockchain. They store information like the balance of each address (which is technically not in the blockchain) so when you ask for the information, it is pulled from the database very quickly. Bitcoin Core does not do this as such databases are a waste of space and most users will not be affected by the slower functionality.

  • What do you mean? Am I using getbalance wrong? I’m trying to follow the Bitcoin.org documentation. – user66764 Dec 3 '17 at 18:41
  • No, you're not using it wrong. Bitcoin Core's getbalance implementation is just slow when many transactions are involved. – Pieter Wuille Dec 3 '17 at 19:20
0

The block explorers will use a "proper" database to allow fast queries. They most likely have some nice hardware behind them too.

You can setup an open source block explorer yourself Example: https://insight.is/

There is a txindex config option for bitcoin that may speed up some commands What are pros and cons of txindex option?

  • I didn't know about this before. Thanks for the info. – user66764 Dec 3 '17 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy