0

I am new to implementing the blockchain locally. Suppose I have a blockchain,

  • How to retrieve the data that is being chained in the blockchain.
  • Is it that only the transaction IDs are saved in the blockchain like the hashes or the actual data being stored in the network.
  • How can I retrieve the data if the latter is the case?
saichand
  • 1,165
  • 1
  • 10
  • 25
  • 1
    Are you looking for assistance with the IBM Blockchain? You've tagged the question with it, but it's not clear from the question or the title. – Andrew Fan Dec 05 '18 at 16:07
  • 1
    I tagged ibm-blockchain, not with any of such intentions but would like to know what it means... – Sai Chand Akella Dec 05 '18 at 16:21
  • 1
    ibm-blockchain refers to the blockchain platform provided by IBM (see: https://www.ibm.com/blockchain). Since you tagged it, I assumed that you were asking for help with that specific platform. – Andrew Fan Dec 05 '18 at 16:22
  • @SaiChandAkella Are you asking how to do this in general or with a specific blockchain platform? – JBaczuk Dec 05 '18 at 17:34
  • 1
    I am asking for the general case. I am still reading about the blockchain architectures and the functionality. I was curious to know how to read the immutable data from the chain. That was my question. – Sai Chand Akella Dec 06 '18 at 05:11

1 Answers1

1

How to retrieve the data that is being chained in the blockchain.

You can store the data however you like. A blockchain is just a data structure similar to a linked list, nothing more. Thus, you can store it as flat file (which Bitcoin Core does), or in database, etc. Bitcoin also stores a LevelDB containing an index of the block files so it knows how and where to retrieve data for a given block. It can also be configured to store an index of every transaction by txid using the -txindex flag at startup of bitcoind.

Is it that only the transaction IDs are saved in the blockchain like the hashes or the actual data being stored in the network.

The blockchain contains all of the transactions that have every occurred on the network. This way all transactions can be validated by all of the participants on the network to make sure there was no double spending, etc. Otherwise you don't know if the coins you received are valid.

How can I retrieve the data if the latter is the case?

How do you want to be able to retrieve the data? If you want to be able to search by block number or block hash, for example, just index the data by block number or block hash. That way you can quickly query the dataset (the blockchain) by block number/hash.

If you want to be able to search for specific transactions, then just index it by txid.

JBaczuk
  • 13,886
  • 10
  • 58
  • 86