Bitcoin Forum

Economy => Service Discussion => Topic started by: ShopemNL on September 25, 2014, 08:08:36 PM



Title: How does blockchain get your address balance?
Post by: ShopemNL on September 25, 2014, 08:08:36 PM
How does blockchain.info calculates your address balance (unspent)?

Do they really have a database with all the transactions?

If yes;
How do they get all the transactions? Do really have a cronjob wich import all the transactions into there db when there is a new block found?

I am trying to check the balance of my addresses in my bitcoin daemon. The easyiest way is to use listunspent and put them in a database. But that will only be fast when the list aint that big.


Title: Re: How does blockchain get your address balance?
Post by: LuaPod on September 26, 2014, 07:02:16 AM
BlockChain implements their own storage methods for the blockchain if I am correct. They have things "pre-indexed" as a laymans term. As you said listunspent is actually a very good method of doing it.


Title: Re: How does blockchain get your address balance?
Post by: shorena on September 26, 2014, 08:04:04 AM
How does blockchain.info calculates your address balance (unspent)?

Do they really have a database with all the transactions?

If yes;
How do they get all the transactions? Do really have a cronjob wich import all the transactions into there db when there is a new block found?

I am trying to check the balance of my addresses in my bitcoin daemon. The easyiest way is to use listunspent and put them in a database. But that will only be fast when the list aint that big.

AFAIK they have a big database that gets updated with every block and confused with every 1000th orso block. Most likely they use blocknotify or a custom client that updates the database. A cronjob makes no sense as you do not know when a new block will be available.


Title: Re: How does blockchain get your address balance?
Post by: DannyHamilton on September 26, 2014, 09:54:31 AM
How does blockchain.info calculates your address balance (unspent)?

You'd have to get access to their source code to know for certain, but they almost certainly run multiple instances of custom designed nodes that index the transactions as they are seen on the network and add them to a custom relational database.

Do they really have a database with all the transactions?

That depends on what you mean by "all" the transactions.  They certainly have all the transactions that are confirmed in the blockchain.  They also have MANY of the transactions that have been broadcast on the network, but which aren't yet confirmed into any blocks.

If yes;
How do they get all the transactions?

You'd have to get access to their source code to know for certain, but they almost certainly run multiple instances of custom designed nodes that index the transactions as they are seen on the network and add them to a custom relational database.

Do really have a cronjob wich import all the transactions into there db when there is a new block found?

Cronjob?  I doubt it.  That would be very inefficient, and too slow.  Far more likely they have multiple daemons that run continuously and add the transactions to their DB as soon as they see it broadcast on the network.

I am trying to check the balance of my addresses in my bitcoin daemon. The easyiest way is to use listunspent and put them in a database.

If you don't use the wallet much, that should work.

But that will only be fast when the list aint that big.

Correct.