0

bitcoin uses blockchain
so blockchain is peer to peer,
every peer stores the data

so I wonder where does the data of all the bitcoins is stored?
who is peer in case of bitcoin?
so that peer gets data related to bitcoins all over the world?

as the bitcoins grow isnt it becomes slower and slower to retrieve information?

2

Each non-pruning full node (peer) stores a complete copy of the blockchain - pruned nodes store a complete copy of the current state, but may not have all historical blocks available.

When a node validates a transaction or a block, it is only validating it against its local view of the blockchain - this means that looking up data is pretty fast, since all of it is available locally.

As the blockchain grows, access time for most data still remains mostly the same due to the nature of the key-value store used by bitcoind - look up times for a key value store are roughly constant, although data that is cached in memory can naturally be accessed faster.

| improve this answer | |
1

To put it simply, blockchain is essentially a history of transactions, with built in measures to confirm that this transaction history cannot be altered. That being said, transactions can be either spent or unspent. Spent transactions are transactions that have already been used as inputs in another transaction. Unspent transactions are transactions that have not been used. It is these unspent transactions that make up your Bitcoin balance. The key thing to understand from this is that you don't actually own a wallet that has Bitcoin in it, you own keys which allow you to spend these unspent transactions by the process of signing.

Since the blockchain is a history of all transactions, it does indeed grow in size and requires more disk space as new blocks are mined. As of today, the Bitcoin blockchain requires around 236 GB of available disk space to store the blockchain data. There are ways in which one can operate a node that does not require the entire history, but that's a topic for another question. Having the entire history of all transactions is useful for tracing the history of a given transaction. If a transaction is going to be used as an input for a new transaction (i.e. you want to send BTC, so you will be spending one or more of your unspent transactions), then the input's prevhash property, or the hash of the transaction in which the coins we are going to spend were received to the given address, can be validated, and the blockchain data can also be queried to ensure that this input has not already been spent. At the end of the day, though, the only thing that says that you have BTC in your wallet are the unspent transactions (abbreviated UTXOs).

We could get into a lot of other topics here, like the fact that the hash of the next block to be mined is based on the hash of the previous block, which can be followed back all the way to the genesis block and ensures that transaction history cannot be altered. We could also get into how the block data propagates through the network, and other important matters like the 51% attack, but the key takeaway I wanted from this response to your question is the notion that your wallet is actually just a keychain, and the keys are what allow you to sign the transactions you've received when you wish to spend them in a new transaction.

So in conclusion, while it seems so simple to say "Well gee, I've got 0.5 BTC, just store that in memory and let me use my money" there is actually a lot more going on behind the scenes, which is important because its what allows Bitcoin to be the trustless distributed and decentralized ledger that it is.

| improve this answer | |

Your Answer

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

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