|
June 24, 2019, 04:05:14 PM Merited by malevolent (1) |
|
You need to look at it in terms of operations you need to support. If you're doing your own validation, you need to be able to lookup any unspent utxo by (txid,vout). You also need to be sure it was only spent once.
There's probably a dozen decent ways to do this, so it's hard to advise you. One thing I'll mention though, that makes it tricky is you generally need to handle "reorgs" where the blockchain literally shifts under your feet.
Generally I've found the easiest way to work with something like the blockchain, is an append-only immutable database. And then you just put indexes for all queries you need to do, to make it fast.
(And the one exception to "immutable" I like to make, is adding a field `isBest` for each block I have, which represents if it's in the most-proof-of-work chain, which makes queries a lot easier and faster)
|