How to index the UTXO set efficiently?

6

3

I haven't been able to find information on how to efficiently index UTXOs. Can you explain or point me to some resources?

Update: Btw, I understand completely that the notion of address balance is awkward at best, and that it can never really be known with 100% confidence, especially as P2SH transactions gain popularity.

stanm87

Posted 2014-10-08T23:11:47.770

Reputation: 237

1Index for what type of querying?Pieter Wuille 2014-10-09T08:24:36.223

1haven't tried anything as I'm not an expert on indices, but have browsed a ton of bitcointalk and couldn't find anything.
@PieterWuille to query balances for addresses.
stanm87 2014-10-09T11:38:59.653

So after doing more digging, here's is what I'm thinking: read the chainstate db from bitcoin core, either directly or via rpc, and then flip the index. I was thinking of putting it in a redis hash, with addresses as keys and transactions as values. This way I can use HSCAN to iterate over the transactions that point to an address and get its balance. The reason I want to use Redis is because this datastructure will be updated quite often, and having everything in RAM is good for that use case. What do you think?stanm87 2014-10-13T15:12:57.660

@NickODell not at allstanm87 2014-10-22T21:09:37.563

Answers

2

I believe what you are looking for is and address based index for txout. Have a look here https://bitcointalk.org/index.php?topic=1395749.msg14194272#msg14194272

Your basic idea of keeping a map of address -> txout is ok. You might want to rethink about storing in memory. Current bitcoind chainstate is around 1.2G (compressed state).

dark knight

Posted 2014-10-08T23:11:47.770

Reputation: 1 532

how can I know the size of the chain state today?Giszmo 2018-01-16T03:21:32.923

Currently its around 3.2 GB . You need to run a bitcoin node and see size of .bitcoin/chainstate directorydark knight 2018-01-16T11:15:49.050