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.
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:
configtx.yaml
in the common/configtx/tool/
directory for more info on the block-cutting criteria.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.