Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Blockchain by (4.1k points)

blockchain is a chain that includes a hash to the previous block. Each block is composed of a single hash tree (or a Merkle Tree). What I am discussing is the overall structure of the blockchain.

Since values of a blockchain are inside of a hash tree, what is the best way to look for a value inside of a block chain? I imagine it would be unfeasible to traverse the entire block chain to search the tree for the value you wish to find. Is there a search method I am missing for searching for a value inside of a block in a blockchain?

1 Answer

0 votes
by (14.4k points)
edited by

As a matter of fact, if a blockchain contains Merkle trees in every block, the data structure is more or less useless when it comes to searching for anything. This is because all hashes in the leaves of the Merkle tree are pseudo-random and therefore contain no usable information about the content of the block. The hash pointing to the previous block is useful for finding the block only and not the content that resides within the block.

So, what we can conclude here is for finding anything in the block, you need to perform a search in real-time.

However, to search anything within the blockchain, what you can do is traverse the blockchain once and build whatever additional data structures you need for finding content in the blockchain.

And on every query, you can use the pre-computed data structures to execute your query efficiently. And when blocks are added to the blockchain, update your pre-computed data structures.

Alternatively, you can influence the design of the blockchain and bake the required data structures to the blockchain from the start itself.

Want to make a career in Blockchain? Then enroll now in Blockchain Training by Intellipaat to get the perfect guidance.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...