> Before learning bitcoin and Ethereum, must first learn its block structure, at that time in the bank to do hyperledger related projects, I was very neglected in the structure, only care about the smart contract, incredibly can also initially master and start Project-related development. This shows that the super-Ledger block attribute is actually weaker, and it is important that the properties of the smart contract. Performance is also good. In this sense, the hyperledger used to do the certificate is overqualified. Question 1: How transactions are deposited into chunks.
Transactions is collected into blocks/batches on the ordering service first. Blocks was cut either when the batchsize was met, or when batchtimeout elapses (provided a non-empty block).
In other words, to satisfy these 2 conditions, the block generates:
The number of trades is enough.
It's time to expire.
So Hyperledger block generation is not timed, peak time, block generation speed significantly faster
Configtx.yaml in the common/configtx/tool/directory for more info on the block-cutting criteria.
The Block type definition in Protos/common/common.proto
Like Ethereum, Hyperledger, there are block numbers, pointers to the previous block, pointers to data, because without digging, the head is a lot simpler.
This was finalized block structure to be shared among the Orderer and peer
Note that the blockheader chains to the previous Blockheader, and the blockdata hash are embedded
In the Blockheader. This makes it natural and obvious that the Data was included in the hash, but
The Metadata is not.
Message Block {
Blockheader Header = 1;
Blockdata data = 2;
Blockmetadata metadata = 3;
}
Blockheader is the element of the block which forms the block chain
The block header is hashed using the configured chain hashing algorithm
Over the ASN.1 encoding of the Blockheader
Message Blockheader {
**uint64 number = 1;**//The position in the blockchain
**bytes Previous_hash = 2;**//The hash of the previous bloc K header
**bytes Data_hash = 3;**//The hash of the Blockdata, by Merkletree
}
Message Blockdata {
Repeated bytes data = 1;
}
Message Blockmetadata {
Repeated bytes metadata = 1;
} question 2: How to deposit Leveldb
These blocks is stored locally to disk on every ordering service node along with a LevelDB to index these blocks by Numbe R–see Orderer/ledger/file
Append a new block to the Ledger
func (fl *fileledger) Append (Block *CB. Block) Error {
err: = Fl.blockStore.AddBlock (block)
if Err = = Nil {
close (fl.signal)
fl.signal = Make ( Chan struct{})
}
return err
}