Author

Topic: Does LevelDB remove spent transaction instantly after creating new block? (Read 97 times)

staff
Activity: 3458
Merit: 6793
Just writing some code
I know that LevelDB stores information about UTXOs in the way like txid->utxos.
Not anymore.



The database is used like an in-memory object. It's a key-value store, so it's basically just an enormous map or dict. So when a block removes a UTXO, it's removed from the database. When one is added, it's added to the database. Of course, there are database transactions and batching so that all of these updates occur atomically, either a block and all of its changes went through, or it didn't. Additionally, LevelDB will cache things in memory with changes only being written out to disk when the cache is full, or at periodic intervals.
jr. member
Activity: 33
Merit: 22
Oh, no. Not after each transaction, ofc. The question was about updating it every block and deleting spent transactions with all spent utxos after each new block. Does it work that way or it deletes spent transactions every 5 blocks for example
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
I can't imagine LevelDB being called that frequently because updating the database after each transaction becomes spent will thrash the database every ~10 mins or constantly (depending on whether LevelDB is updated when a block is received or a transaction is received).
jr. member
Activity: 33
Merit: 22
I know that LevelDB stores information about UTXOs in the way like txid->utxos. And when all utxos are spent in this transaction, it is removed from DB. But is it an instant action after new block was created, where the last unspent vout becomes spent?
I mean when the last unspent vout is in DB for txid X and it is spent in the block N, it will be removed from DB after block N instantly?
And also I can’t understand the thing about the structure of value in LevelDB which is in chainstate/ folder
I’ve seen smth that it stores data like hight, number of vout, is this vout spent or not, and smth else but I don’t remember what. If I’m not right, correct me please.
Jump to: