Reputation: 846
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
Upvotes: 11
Views: 13657
Reputation: 4667
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.
Upvotes: 6
Reputation: 2601
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.
Upvotes: 13
Reputation: 30
It is stored in Ledgers. Now that ledger can adopt any NO-SQL tech-stack.
Upvotes: -2
Reputation: 937
It depends on the implementation of node client. Almost all of them use key-value storage for efficiency. To name a few specifically:
Upvotes: 5