Hyperledger data storage

At this level, let's introduce an important concept in Hyperledger—the world state. 

As you will have noticed, at the end of the createRawFood function we called the putState(key, value) method to store or update any validated state values on the ledger.

Here, a question can be raised about data immutability: Does the putState function change the data in the blockchain? In Hyperledger Fabric we need to make a distinction between two parts of the ledger—the world state and the blockchain.

The world state is a database that stores (as a key value pair) the current values of all ledger states (all Chaincode states). It is populated when each peer validates and commits a transaction. Fabric supports two database infrastructure options for state databases including LevelDB, as used by Ethereum, and CouchDB. The former is the default state database, which supports key value storage, while the latter is a more advanced choice used to store complex data types to support business functions. However, Fabric provides a flexible pluggable design for state databases, meaning it can be configured to use other types of database.

The second part is the blockchain. It represents a transaction log that records all historical changes of the world state, and is a file-based ledger which stores an immutable sequence of blocks, and contains a set of ordered transaction data. 

Given that, we understand now that putState(key, value) will update the ledger state data in the world state, and the transaction log will keep the entire state data as an immutable record visible only to permitted nodes in the blockchain. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset