Block structure of Hyperledger

Source: Internet
Author: User
Tags hash

> 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

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.