I have a query, where do blockchain data saved in every node. After a long search in google, StackOverflow, and some blogs, like got many answers: like: it saved in a database like level-DB or rocks-DB, some said it saves in memory in a variable, some said it saved in a file (from hyperledger-fabric).
I want to know, is there a particular method of storing blocks which are followed by most blockchain framework?
Or all those frameworks choose different methods (like file, memory, or DB).
I know there is a current state/world state of blockchain which is saved in a database. This current state/world state is totally different from actual blockchain. In the current state or world state, the data can be modified, but in actual blockchain block/data is immutable.
So to be concise, my question is:
How the data (immutable blocks) stored on the ledger of every full nodes in a Blockchain ? is it in Memory, in a file (like JSON, CSV file ), or in DB
Blockchain does not store any of its information in a central location. Instead, the blockchain is copied and spread across a network of computers. Whenever a new block is added to the blockchain, every computer on the network updates its blockchain to reflect the change.
Blockchains are used as a digital ledger to store transactional information. The data is stored as signed blocks, which link to each other, creating a chain of immutable interconnected data entries. To sign a new block, a node needs to find an SHA-256 signature that matches specific criteria.
When an NFT is purchased, a record (code) is created, pointing to the location the NFT is stored on the blockchain. That record or code is then stored within a digital wallet. The most common digital wallet is MetaMask and NFTexplained.info has a full guide for setting this popular wallet up; that can be found here.
Bitcoin nodes keep raw block data on disk in files .bitcoin/blocks/blk*.dat. Size of each blknnnnnn.dat is 128MB, with the total size of data as of today ~300GB. Metadata about all known blocks is kept in Level DB files in .bitcoin/blocks/index/nnnnnn.ldb files.
Blockchain is a distributed database. This means that data is scattered around the nodes (participating computers). Each node can decide how to store data (and if to store it at all).
When you are accessing the data, you are in fact sending messages to nodes on the network. In principle, you don't have to store any part of the blockchain on your computer if you only want to send transactions. The blockchain protocol guarantees that you can reconstruct the data from pieces of received information correctly and trustfully.
As for every node, the storage depends entirely on how the software was written and configured to run. For large blockchains such as Ethereum and Bitcoin, the entire blockchain data is in order of hundreds of gigabytes, so if you configure your software to store it locally the software will typically download a number of large files from other computers and store it on your disk. For some programs, authors might prefer to use a database over files. And in most cases, parts of the data will be kept in memory temporarily by OS cache and program's own data structures.
It depends on the implementation of node client. Almost all of them use key-value storage for efficiency. To name a few specifically:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With