Closed jiebanghan closed 7 years ago
The state is stored in a special data structure called a Merkle-Patricia trie, inside leveldb. Imagine it as a prefix-trie containing all the accounts by address, where each "leaf" representing an account contains yet another prefix-trie containing all the stored state by hash. Spice this up with crypto guarantees instead of a plain prefix-trie, and you get the Merkle-Patricia trie. :)
Thank you. is the data permeantly stored in the database even if all the nodes in the ethereum network are power cut? I just mean I want to store some important information in smart contract , is it stored in hardware and does not disappear even if all the nodes are power cut? thank you.
The data will remain on disk for the nodes yes, you can start the node up later and your data will be available. Also if you have the chain itself (blocks containing the transaction), you can always reconstruct the state itself, since the blocks were used originally to generate the state in the first place.
Thank you very much for speaking with me.
mapping(bytes32 => bytes32) private userPasswds ;
By the way, is the data (userPasswds) secure? 1) Can anyone can visit by Web3.js? 2) Can anyone can access the data stored in blockchain?
Thx
Can i think like this? The trx in block is similar with the redo log
of mysql innodb , and state in level is similar with the data page
of innodb. Is there some document about how ethereum store the data?
Please refer the below article, it neatly explains the concepts. https://hackernoon.com/getting-deep-into-ethereum-how-data-is-stored-in-ethereum-e3f669d96033
@karalabe , @jiebanghan - This part of the question always excites me - As I understood , hash is one way , once hash applied - there is no way to retrieve the data , however , it is easy to verify the data. In that case, data is stored in terms of hashes in blockchain - how data retrieval happens say when the user is looking at the transactions etc ...
I am just wrting contracts, and there are some variable definition such as: mapping(bytes32 => bytes32) private userPasswds ; and you know its aim is to store some values. My question is where does the data store? is it in blockchain or in database( in Ethereum ,the state dababase is goleveldb)? If it is stored in database, is it permeant even if all the nodes are power cut.