0

As per this post bitcoin nodes do not maintain an index from addresses to TxIDs and hence querying for the unspent tokens by addresses essentially involves traversing the entire UTXO set.

However, the blockchain explorers enable search by addresses not just on the unspent outputs but on the entire blockchain. They list all the transactions that involve an address. I have the following questions:

  • How do the block explorers do the search by addresses -- do they search the entire blockchain at query time, which is very inefficient, or do they maintain some sort of index which they update iteratively?
  • If they maintain an index, it looks like the index will be pretty huge since it will always keep on growing. So how big is the index currently?
  • Also, can the blockchain nodes currently do such a search (of course efficiently)?

1 Answer 1

2

How do the block explorers do the search by addresses -- do they search the entire blockchain at query time, which is very inefficient, or do they maintain some sort of index which they update iteratively?

The block explorers parse all of the transactions one by one and create their own database and index using the address generated from the scriptPubKeys. This is expensive the first time, but not as bad when it just needs to stay up to date.

If they maintain the index, it looks like the index will be pretty huge since it will always keep on growing. So how big is the index currently?

It is at least as big as the blockchain itself (assuming they are storing all of the data, raw blocks, etc.). As for the specific number, you'd have to ask the specific block explorer.

Also, can the blockchain nodes currently do such a search (of course efficiently)?

If you enable -txindex flag you can search by txid but Bitcoin-core offers no such functionality (search by address) unless it is one of your wallet addresses.

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.