Bitcoin Forum
April 23, 2024, 02:47:32 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: What data LevelDB stores?  (Read 132 times)
BoyFromDubai (OP)
Jr. Member
*
Offline Offline

Activity: 33
Merit: 22


View Profile
February 09, 2023, 12:19:19 AM
Merited by vapourminer (2), ABCbits (1)
 #1

I know that LevelDB stores information about current UTXO in the whole network. But what data exactly in this database, that allows nodes create transactions? For example in a block the fields are: previous hash, timestamp, merkle root, nonce, difficulty and etc. But what are the fields in LevelDB?
1713883652
Hero Member
*
Offline Offline

Posts: 1713883652

View Profile Personal Message (Offline)

Ignore
1713883652
Reply with quote  #2

1713883652
Report to moderator
1713883652
Hero Member
*
Offline Offline

Posts: 1713883652

View Profile Personal Message (Offline)

Ignore
1713883652
Reply with quote  #2

1713883652
Report to moderator
"In a nutshell, the network works like a distributed timestamp server, stamping the first transaction to spend a coin. It takes advantage of the nature of information being easy to spread but hard to stifle." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713883652
Hero Member
*
Offline Offline

Posts: 1713883652

View Profile Personal Message (Offline)

Ignore
1713883652
Reply with quote  #2

1713883652
Report to moderator
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3374
Merit: 6531


Just writing some code


View Profile WWW
February 09, 2023, 04:04:03 AM
Merited by ABCbits (1)
 #2

It's a key-value store of outpoint to transaction output. Outpoints consist of the txid and output index, and transaction output is the amount in satoshis and the output script. These are the pieces from previous transactions that's needed to verify a transaction.

Omair Amin
Newbie
*
Offline Offline

Activity: 1078
Merit: 0


View Profile
February 09, 2023, 08:30:30 AM
Last edit: February 09, 2023, 10:29:31 AM by Mr. Big
 #3

Some Bitcoin network implementations use LevelDB, a key-value store, to keep track of the outputs of unspent transactions (UTXOs). In LevelDB, the key-value pairs stand in for the UTXOs and the related data required to verify transactions and build new blocks.

The hash of the transaction that created the UTXO and the index of the output in that transaction are combined to create each key in the LevelDB database, which represents a UTXO. Each key's value consists of a binary representation of the output's script and its associated Bitcoin balance.



The set of unconfirmed transactions, the best known block header, and various metadata required to validate transactions and blocks are just a few examples of the additional data that LevelDB can hold in addition to the UTXO data regarding the health of the Bitcoin network.

It's crucial to note that since there is no set format for this data, the precise fields and structure of the data saved in LevelDB may differ between different Bitcoin protocol implementations.
BoyFromDubai (OP)
Jr. Member
*
Offline Offline

Activity: 33
Merit: 22


View Profile
February 09, 2023, 11:21:00 AM
 #4

But what kind of data about UTXO is stored in there? I've heard that it's like txid -> data about all UTXOs, but what kind of data? Saw that there are some bits that indicates if a vout is spent or not. And when all bits show that all vouts are spent, this pair txid -> vouts will be deleted
ABCbits
Legendary
*
Offline Offline

Activity: 2856
Merit: 7403


Crypto Swap Exchange


View Profile
February 09, 2023, 12:32:39 PM
Merited by vapourminer (1), NotATether (1)
 #5

The set of unconfirmed transactions, the best known block header, and various metadata required to validate transactions and blocks are just a few examples of the additional data that LevelDB can hold in addition to the UTXO data regarding the health of the Bitcoin network.

Bitcoin Core documentation doesn't mention mempool (on memory or dump file "mempool.dat") use LevelDB though[1].

But what kind of data about UTXO is stored in there? I've heard that it's like txid -> data about all UTXOs, but what kind of data? Saw that there are some bits that indicates if a vout is spent or not. And when all bits show that all vouts are spent, this pair txid -> vouts will be deleted

See https://bitcoin.stackexchange.com/a/29418.

[1] https://github.com/bitcoin/bitcoin/blob/v24.0.1/doc/files.md

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
BoyFromDubai (OP)
Jr. Member
*
Offline Offline

Activity: 33
Merit: 22


View Profile
February 09, 2023, 08:09:11 PM
 #6



What do these letters at the beginning mean? 'c' + smth it means that a key consists of the letter c at the begging + smth?
ABCbits
Legendary
*
Offline Offline

Activity: 2856
Merit: 7403


Crypto Swap Exchange


View Profile
February 10, 2023, 11:15:50 AM
Merited by vapourminer (1), PowerGlove (1)
 #7

What do these letters at the beginning mean? 'c' + smth it means that a key consists of the letter c at the begging + smth?

Correct. But if you decide to read LevelDB file directly, take note Bitcoin Core has obfuscation key[1] to prevent data corruption due to false positive from Anti virus[2].

[1] https://bitcoin.stackexchange.com/a/52167
[2] https://github.com/bitcoin/bitcoin/issues/6613

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
BoyFromDubai (OP)
Jr. Member
*
Offline Offline

Activity: 33
Merit: 22


View Profile
April 09, 2023, 08:11:16 PM
 #8

Can one explain please what does "'C'+ 32-byte transaction hash + output index length + output index" mean? In this answer https://bitcoin.stackexchange.com/questions/28168/what-are-the-keys-used-in-the-blockchain-leveldb-ie-what-are-the-keyvalue-pair/29418#29418
Firstly i decided, that hex C is stored in DB, but then I saw in there other letters, like T, or R, which are not hex numbers. So does that mean, that it's real letters, which are decoded in bytes via utf-8 for example?
And also it's not clear what output index length means. It means that if real vout index is 16 for example, then in bytes it's compared to '10' which has length of 2, and this output index length == '2' in bytes? And for vout 4096 for example hex representation is '1000', which has length of 4 bytes.
If so, then it's a bit strange. Is there any limit for the number of vouts per transaction, or I can send coins for a million users for example?
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!