how exactly blocks are created in hyperledger fabric

后端 未结 3 772
没有蜡笔的小新
没有蜡笔的小新 2021-02-03 14:54

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.

3条回答
  •  清歌不尽
    2021-02-03 15:20

    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.

提交回复
热议问题