
Apr 1, 2022
·
4 min read
·
Listen
LevelDB — Invented by Google and used by cryptocurrencies like Bitcoin (₿)
What is LevelDb?
LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values. Apart from being open-source, it is written in C++ and was launched in 2011.
Moreover, LevelDB is an LSM-based key-value store that offers enhanced write throughput and reasonable read throughput. Essentially, LevelDB excels at random reads and writes.
How it is used by Bitcoin & Ethereum?
Before moving on that how does it uses LevelDB to store data, we first need to understand what are UTXO (unspent transaction output) in any cryptocurrency.
Let’s assume you receive 5 ₿ from your father, 3 ₿ from your mother and 2 ₿ from a shop keeper. You have 3 UTXO.
Bitcoin wallet balance = 5 ₿ + 3 ₿ + 2 ₿
In total you had 10 ₿. Now, you went to purchase a gadget which was priced at 6.98 ₿. Since you had enough Bitcoins, you transferred 5 ₿ & 2 ₿ for the gadget.
Bitcoin wallet balance = 3 ₿
Since, the remaining balance 0.02 ₿ was left. You get 0.01 ₿ back because 0.01 ₿ is deducted as the fee for the transaction. Now, you converted 3 UTOX to 2 UTOX.
Bitcoin wallet balance = 3 ₿ + 0.01 ₿
In general, Bitcoin could be any number instead of fixed numbers as we have in any currency like dollars. The minimum value it should be is 1 Satoshi.
Note: 100 million Satoshis == 1 Bitcoin
Let’s look how does LevelDb comes in picture.
When ever a transaction occur, we all know that basically every cryptocurrency is a blocks of chain or it can be assumed as ledgers.
Bitcoin works on mechanism of Transaction ledgers.
Ethereum works on mechanism of Balance ledges.
Crypto blocks just contain the relevant information about the transaction such as:
- Previous hash of the block.
- Merkel tree root hash.
- Nonce.
- Spent transaction output hash.
- Etc, depending upon cryptocurrencies.
There are four pieces of data that are maintained
- blocks/blk*.dat
- blocks/index/*
- chainstate/*
- blocks/rev*.dat
Among these lets discuss more about chainstate/* & blocks/index/*.
blocks/index/*: this is a LevelDB database that contains metadata about all known blocks, and where to find them on disk. Without this, finding a block would be very slow.
Chainstate/*: this is a LevelDB database with a compact representation of all currently UTXO’s and some metadata about the transactions they are from. The data here is necessary for validating new incoming blocks and transactions. It can theoretically be rebuilt from the block data, but this takes a rather long time. Without it, you could still theoretically do validation indeed, but it would mean a full scan through the blocks (398.37 GB as of 31 March, 2022) for every output being spent.
Why LevelDB?
The LevelDB’s are redundant in the sense that they can be rebuilt from the block data. But validation and other operations would become intolerably slow without them.

References
What is LevelDB and how does it work?
Databases form an important part of an application stack, after the server and client side parts of it have been…
Bitcoin Core 0.11 (ch 2): Data Storage
This page describes how & where Bitcoin Core stores blockchain data. There are basically four pieces of data that are…
What is the database for?
Thanks for contributing an answer to Bitcoin Stack Exchange! Please be sure to answer the question. Provide details and…
LevelDB – Wikipedia
LevelDB is an open-source on-disk key-value store written by Google fellows Jeffrey Dean and Sanjay Ghemawat. Inspired…
GitHub – google/leveldb: LevelDB is a fast key-value storage library written at Google that…
LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to…
Join Coinmonks Telegram Channel and Youtube Channel learn about crypto trading and investing
Also, Read
- What are the Trading Signals? | Bitstamp vs Coinbase | Buy Solana
- ProfitFarmers Review | How to use Cornix Trading Bot
- 10 Best Cryptocurrency Blogs | YouHodler Review
- MyConstant Review | 8 Best Swing Trading Bots
- MXC Exchange Review | Pionex vs Binance | Pionex Arbitrage Bot
14
14
Sign up for Coinmonks
By Coinmonks
A newsletter that brings you day’s best crypto news, Technical analysis, Discount Offers, and MEMEs directly in your inbox, by CoinCodeCap.com Take a look.
Get this newsletter
By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.
More from Coinmonks
Follow
Coinmonks (http://coinmonks.io/) is a non-profit Crypto Educational Publication. Follow us on Twitter @coinmonks and Our other project — https://coincodecap.com, Email — gaurav@coincodecap.com
Zilliqa grew 500% in the last week. Is it undervalued?

Share your ideas with millions of readers.

Hummingbird Finance & NestSwap
Metalandz joins NestSwap to offer yield farming and a staking pool for holders


March Overview


Member-only
Prepare The Pitchforks: Harmful EU Crypto Regulations

VeriDoc Ledger: A Blockchain Fit for Government and Enterprise

Recommended from Medium

Boys club: Fewer than 1 in 10 crypto investors is female (From Yahoo Finance by Rubina Ahmed-Haq)

🚀 Boosted Finance: Strategist Competition Kickoff


AMA RECAP WITH CASSAVA NETWORK


DeFi Watcher


Two Weird Things Have Happened Lately… Did You Notice?

OrcaDAO x Lydia Finance Partnership

