Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how exactly blocks are created in hyperledger fabric

I am going through hyperledger fabric V1.0. Need to know the internals of hyper-ledger.

1) How and where the blocks and transactions are saved in hyperledger internally.

2) Is it in the NoSQL DB (Level DB, Couch DB) ??. If yes, what is the structure, in the way it is getting saved ??.

3) Where can I find the end to end setup doc for V1.0 (which includes CA, fabric, orderer setup. Currently I am following the link, which is getting updated.

https://hyperledger-fabric.readthedocs.io/

like image 942
Pradeep Padmarajaiah Avatar asked Mar 13 '17 04:03

Pradeep Padmarajaiah


1 Answers

For all the code references below, use the fabric git repo as your guide. (S/O prevents me from posting more than 2 links, so I'm unable to link to the code fragments directly.)

Transactions are collected into blocks/batches on the ordering service first. Blocks are cut either when the BatchSize is met, or when BatchTimeout elapses (provided a non-empty block).

Refer to:

  1. configtx.yaml in the common/configtx/tool/ directory for more info on the block-cutting criteria.
  2. The Block type definition in protos/common/common.proto.

These blocks are stored locally to disk on every ordering service node along with a LevelDB to index these blocks by number -- see orderer/ledger/file.

These blocks are then delivered (via the ordering service's Deliver RPC) to committing peers. They store them locally, and maintain a LevelDB-based block index (similar to the one for the orderers), a LevelDB-based history index to track the history of each key on the blockchain, and a state database that maintains the latest values for all the keys on the blockchain. This state DB can be either LevelDB or CouchDB-based. See the ledger doc for more info.

PS: Question #3 is irrelevant and should be broken off to a separate thread.

like image 200
Kostas Avatar answered Dec 20 '22 16:12

Kostas