Bitcoin Forum
May 04, 2024, 08:55:42 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Does LevelDB remove spent transaction instantly after creating new block?  (Read 80 times)
BoyFromDubai (OP)
Jr. Member
*
Offline Offline

Activity: 33
Merit: 22


View Profile
December 20, 2022, 12:11:16 PM
Last edit: December 20, 2022, 12:38:23 PM by BoyFromDubai
Merited by ABCbits (1)
 #1

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.
1714812942
Hero Member
*
Offline Offline

Posts: 1714812942

View Profile Personal Message (Offline)

Ignore
1714812942
Reply with quote  #2

1714812942
Report to moderator
Every time a block is mined, a certain amount of BTC (called the subsidy) is created out of thin air and given to the miner. The subsidy halves every four years and will reach 0 in about 130 years.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714812942
Hero Member
*
Offline Offline

Posts: 1714812942

View Profile Personal Message (Offline)

Ignore
1714812942
Reply with quote  #2

1714812942
Report to moderator
1714812942
Hero Member
*
Offline Offline

Posts: 1714812942

View Profile Personal Message (Offline)

Ignore
1714812942
Reply with quote  #2

1714812942
Report to moderator
NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6727


bitcoincleanup.com / bitmixlist.org


View Profile WWW
December 20, 2022, 02:19:56 PM
 #2

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).

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
BoyFromDubai (OP)
Jr. Member
*
Offline Offline

Activity: 33
Merit: 22


View Profile
December 20, 2022, 02:22:46 PM
 #3

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
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6578


Just writing some code


View Profile WWW
December 20, 2022, 07:09:17 PM
 #4

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.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!