Bitcoin Forum
September 13, 2024, 07:55:17 PM *
News: Latest Bitcoin Core release: 27.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How does blockchain get your address balance?  (Read 871 times)
ShopemNL (OP)
Legendary
*
Offline Offline

Activity: 1025
Merit: 1001



View Profile WWW
September 25, 2014, 08:08:36 PM
Last edit: September 25, 2014, 08:25:37 PM by ShopemNL
 #1

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.

LuaPod
Newbie
*
Offline Offline

Activity: 28
Merit: 0


View Profile
September 26, 2014, 07:02:16 AM
 #2

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.
shorena
Copper Member
Legendary
*
Offline Offline

Activity: 1498
Merit: 1530


No I dont escrow anymore.


View Profile WWW
September 26, 2014, 08:04:04 AM
 #3

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.

Im not really here, its just your imagination.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3472
Merit: 4796



View Profile
September 26, 2014, 09:54:31 AM
 #4

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.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!