Author

Topic: How does bitcoin store the utxo set? (Read 249 times)

legendary
Activity: 1806
Merit: 1828
November 03, 2018, 10:56:04 AM
#4

Okay thanks. This seems like something that could be easily optimised no? Instead of having a tonne of duplicated data that is both in the utxo db and blocks db. You could have each block, and each tx that tries to spend utxo's (instead of referencing a previous tx hash), references a block number and position in the block of the tx he is trying to spend. then the client finds the tx and position of the utxo inside the tx and checks the lockscript/unlockscript.

The chainstate database is the optimization. You can now run a pruned node that only stores a few hundred blocks and with chainstate you still have a fully validating node.
member
Activity: 183
Merit: 25
November 03, 2018, 10:30:42 AM
#3
IS the utxo set stored independently from the block set?

Yes. It's called chainstate, few call it UTXO set.

how does bitcoin search the db for a given utxo to verify a transaction is legitimate if it just stores the blocks?

By access chainstate, not access blocks

Okay thanks. This seems like something that could be easily optimised no? Instead of having a tonne of duplicated data that is both in the utxo db and blocks db. You could have each block, and each tx that tries to spend utxo's (instead of referencing a previous tx hash), references a block number and position in the block of the tx he is trying to spend. then the client finds the tx and position of the utxo inside the tx and checks the lockscript/unlockscript.
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
November 03, 2018, 10:26:22 AM
#2
IS the utxo set stored independently from the block set?

Yes. It's called chainstate, few call it UTXO set.

so for each block that comes in you store;
block (Key: BlockHash)
then extract each tx and store;
tx (Key: TxHash)

AFAIK it's true, chainstate uses key/value pair method which contain TX hash and block hash.

how does bitcoin search the db for a given utxo to verify a transaction is legitimate if it just stores the blocks?

By access chainstate, not access blocks
member
Activity: 183
Merit: 25
November 03, 2018, 10:17:53 AM
#1
IS the utxo set stored independently from the block set?

so for each block that comes in you store;
block (Key: BlockHash)
then extract each tx and store;
tx (Key: TxHash)

or is it all stored inside blocks? how does bitcoin search the db for a given utxo to verify a transaction is legitimate if it just stores the blocks?
Jump to: