1

If I want the latest information (ie. account balance) of account A do I have to traverse the entire block chain to get that info or is the relevant information store in the latest block or some other companion data structure?

If I have to traverse the entire block chain, is there going to be scalable problem as block chain grows?

2
  • 2
    Possible duplicate of How is a wallet's balance computed?
    – alcio
    Aug 3, 2017 at 9:18
  • I'm voting to leave open. While the proposed duplicate is closely related it doesn't comprehensively address scalability or complexity of calculating the balances.
    – Murch
    Aug 5, 2017 at 20:59

1 Answer 1

0

You have to traverse entire blockchain. At the lowest bitcoin level there is no accounts, there is concept of "unspent output". Bitсoin clients (excluding light versions) should support index of all transactions with unspent output, in order to validate transactions quickly. That means bitcoin clients doesn't actually scan entire blockchain, they just know balance of all accounts.

You are right, it can cause scalability problem, if bitcoin become more valuable, and count of transactions with unspent output will grow very quickly.

5
  • the index part sounds nice but could also be a bottle neck right? there is about 1 billion credit cards in use right now, assuming there is 1 billion bitcoin user and each meta data cost 1kb that is 1 terabyte of index. Is there propose solution to solve these scalability problem?
    – Jal
    Aug 2, 2017 at 21:53
  • Bitcoin wasn't designed to replace existing credit cards. It was designed as decentralized, and any user with PC should be able to run full bitcoin node. But even now it requires very good PC with quick hard drive and good internet connection. So, at the current time and current technology level bitcoin network cannot handle 1 billion active users. I don't like when people compare bitcoin to Visa/Mastercard and other very high load payment systems.
    – Zergatul
    Aug 2, 2017 at 22:00
  • ah I see, sorry for the comparison, its just that I see alot of argument on how bitcoin can replace fiat and facilitate machine to machine transaction, so I wanted to understand the fundamental infrastructure a bit more.
    – Jal
    Aug 2, 2017 at 22:04
  • Bitcoin Core does not have an index of transactions anymore since 0.8. Instead, there is a database with just the unspent outputs (not an index into the chain, just a copy of all outputs). During validation, the blocks and transactions aren't accessed anymore - only the database is consulted and updated. Aug 3, 2017 at 5:42
  • @PieterWuille That's is what I meant, maybe it wasn't clear. In terms of relative databases, we would say, there is 2 tables, one is blockchain, second is unspent outputs. Index on top of second allows to validate transations in O(log m), where m is number of unspent outputs
    – Zergatul
    Aug 3, 2017 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.