Bitcoin Forum
May 25, 2024, 10:10:55 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: LevelDB and blockchain.  (Read 145 times)
satscraper (OP)
Hero Member
*****
Offline Offline

Activity: 742
Merit: 1404



View Profile
August 10, 2022, 08:27:41 AM
 #1

Hi to all. I'm relatively new to bitcoin technicalities and in my understanding it is  solely the responsibility of every node to hold up levelDB of bitcoin feeding it up and  renewing with  the data obtained from other nodes. LevelDB itself is not in blockchain. If not so, feel free to shoot it down in flames.

███████████████████████████
███████▄████████████▄██████
████████▄████████▄████████
███▀█████▀▄███▄▀█████▀███
█████▀█▀▄██▀▀▀██▄▀█▀█████
███████▄███████████▄███████
███████████████████████████
███████▀███████████▀███████
████▄██▄▀██▄▄▄██▀▄██▄████
████▄████▄▀███▀▄████▄████
██▄███▀▀█▀██████▀█▀███▄███
██▀█▀████████████████▀█▀███
███████████████████████████
.
.Duelbits.
..........UNLEASH..........
THE ULTIMATE
GAMING EXPERIENCE
DUELBITS
FANTASY
SPORTS
████▄▄█████▄▄
░▄████
███████████▄
▐███
███████████████▄
███
████████████████
███
████████████████▌
███
██████████████████
████████████████▀▀▀
███████████████▌
███████████████▌
████████████████
████████████████
████████████████
████▀▀███████▀▀
.
▬▬
VS
▬▬
████▄▄▄█████▄▄▄
░▄████████████████▄
▐██████████████████▄
████████████████████
████████████████████▌
█████████████████████
███████████████████
███████████████▌
███████████████▌
████████████████
████████████████
████████████████
████▀▀███████▀▀
/// PLAY FOR  FREE  ///
WIN FOR REAL
..PLAY NOW..
pooya87
Legendary
*
Offline Offline

Activity: 3458
Merit: 10589



View Profile
August 10, 2022, 08:38:14 AM
Merited by ABCbits (1), BlackHatCoiner (1)
 #2

it is  solely the responsibility of every node to hold up levelDB of bitcoin feeding it up and  renewing with  the data obtained from other nodes.
The responsibility of a full node is to download and verify all the blocks from the start until the last one while enforcing consensus rules. What database that node uses to store the blockchain and the related data is not important at all. In other words LevelDB is just one of many possible key-value stores that could be used to store the bitcoin related data such as the chainstate.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
NotATether
Legendary
*
Offline Offline

Activity: 1610
Merit: 6761


bitcoincleanup.com / bitmixlist.org


View Profile WWW
August 10, 2022, 09:32:06 AM
 #3

LevelDB itself is not in blockchain. If not so, feel free to shoot it down in flames.

While the database itself isn't serialized inside the blockchain, we know that the blockchain consists of blocks, the data of which is stored inside levelDB databases.

So the entirety of all the blocks is stored in the blockchain, but as @pooya87 said, a storage medium is needed for all those blocks, and so that's where LevelDB comes in.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Accardo
Hero Member
*****
Offline Offline

Activity: 1092
Merit: 510


Leading Crypto Sports Betting & Casino Platform


View Profile
August 12, 2022, 06:46:58 AM
Merited by n0nce (1)
 #4

Level DB is a database that works with no SQL which can be used to store data not only for Bitcoin any project can make use of it, as the database is leveled on choosing what key and value you want to store in the program or get from the database. A running Bitcoin node saves Bitcoin related data on block or chainstate directories, then the leveldb can be used to call those files saved in the directory. For instance we can retrieve a bunch of key values from the blocks index using one operation.  

Code:
const level = require('level')
const db = level('my-db')

const ops = [
  { type: 'get', key: 'block' },
  { type: 'get', key: 'b'+32, value: 'byte block hash' },
  { type: 'get', key: 'F+4', value: 'byte file number' },
  { type: 'get', key: 'I-4', value: 'byte file number' },
  { type: 'get', key: 't+32', value: 'byte transaction hash' }
]

db.batch(ops, function (err) {
  if (err){
     return console.log(err)
  }
  console.log('Great success')
})
We have an ops array with a bunch of objects to define the operations.

The type is the type of the operation we want to do. They are the same as the method names.

The key is needed for getting the items to delete.

And the value is what we insert as the value of the key

Other additional functions include;

Get- get a key from the database
Put- put a value from the database
Del - delete a key in the current range
L.S- get all the keys in the current range
Start - defines the start of the current range
End - denfine the end of the current range


This will help you get to know leveldb better

https://bitcoindev.network/understanding-the-data/amp/

https://thewebdev.info/2020/09/21/node-js-basics%E2%80%8A-%E2%80%8Alevel-db/

https://imil.net/blog/posts/2020/bitcoin-leveldb-debugging/

..Stake.com..   ▄████████████████████████████████████▄
   ██ ▄▄▄▄▄▄▄▄▄▄            ▄▄▄▄▄▄▄▄▄▄ ██  ▄████▄
   ██ ▀▀▀▀▀▀▀▀▀▀ ██████████ ▀▀▀▀▀▀▀▀▀▀ ██  ██████
   ██ ██████████ ██      ██ ██████████ ██   ▀██▀
   ██ ██      ██ ██████  ██ ██      ██ ██    ██
   ██ ██████  ██ █████  ███ ██████  ██ ████▄ ██
   ██ █████  ███ ████  ████ █████  ███ ████████
   ██ ████  ████ ██████████ ████  ████ ████▀
   ██ ██████████ ▄▄▄▄▄▄▄▄▄▄ ██████████ ██
   ██            ▀▀▀▀▀▀▀▀▀▀            ██ 
   ▀█████████▀ ▄████████████▄ ▀█████████▀
  ▄▄▄▄▄▄▄▄▄▄▄▄███  ██  ██  ███▄▄▄▄▄▄▄▄▄▄▄▄
 ██████████████████████████████████████████
▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄
█  ▄▀▄             █▀▀█▀▄▄
█  █▀█             █  ▐  ▐▌
█       ▄██▄       █  ▌  █
█     ▄██████▄     █  ▌ ▐▌
█    ██████████    █ ▐  █
█   ▐██████████▌   █ ▐ ▐▌
█    ▀▀██████▀▀    █ ▌ █
█     ▄▄▄██▄▄▄     █ ▌▐▌
█                  █▐ █
█                  █▐▐▌
█                  █▐█
▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀█
▄▄█████████▄▄
▄██▀▀▀▀█████▀▀▀▀██▄
▄█▀       ▐█▌       ▀█▄
██         ▐█▌         ██
████▄     ▄█████▄     ▄████
████████▄███████████▄████████
███▀    █████████████    ▀███
██       ███████████       ██
▀█▄       █████████       ▄█▀
▀█▄    ▄██▀▀▀▀▀▀▀██▄  ▄▄▄█▀
▀███████         ███████▀
▀█████▄       ▄█████▀
▀▀▀███▄▄▄███▀▀▀
..PLAY NOW..
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!