Hyperledger Fabric 关于出块时间和区块大小

2022/03/04 15:36
阅读数 1.4K

Hyperledger Fabric 关于出块时间和区块大小

刚开始接触 fabric 的同学可能会有这样的疑问:为什么每个区块里就只有一笔交易呢?会产生这样的疑问很正常,说明有去认真仔细的观察和思考了。

决定区块大小的配置在通道配置文件 configtx.yaml 中:

Orderer: &OrdererDefaults

    OrdererType: solo

        # -

    # Batch Timeout: The amount of time to wait before creating a batch.
    BatchTimeout: 2s

    # Batch Size: Controls the number of messages batched into a block.
    # The orderer views messages opaquely, but typically, messages may
    # be considered to be Fabric transactions.  The 'batch' is the group
    # of messages in the 'data' field of the block.  Blocks will be a few kb
    # larger than the batch size, when signatures, hashes, and other metadata
    # is applied.

        # Max Message Count: The maximum number of messages to permit in a
        # batch.  No block will contain more than this number of messages.
        MaxMessageCount: 500

        # Absolute Max Bytes: The absolute maximum number of bytes allowed for
        # the serialized messages in a batch. The maximum block size is this value
        # plus the size of the associated metadata (usually a few KB depending
        # upon the size of the signing identities). Any transaction larger than
        # this value will be rejected by ordering.
        # It is recommended not to exceed 49 MB, given the default grpc max message size of 100 MB
        # configured on orderer and peer nodes (and allowing for message expansion during communication).
        AbsoluteMaxBytes: 10 MB

        # Preferred Max Bytes: The preferred maximum number of bytes allowed
        # for the serialized messages in a batch. Roughly, this field may be considered
        # the best effort maximum size of a batch. A batch will fill with messages
        # until this size is reached (or the max message count, or batch timeout is
        # exceeded).  If adding a new message to the batch would cause the batch to
        # exceed the preferred max bytes, then the current batch is closed and written
        # to a block, and a new batch containing the new message is created.  If a
        # message larger than the preferred max bytes is received, then its batch
        # will contain only that message.  Because messages may be larger than
        # preferred max bytes (up to AbsoluteMaxBytes), some batches may exceed
        # the preferred max bytes, but will always contain exactly one transaction.
        PreferredMaxBytes: 2 MB

BatchTimeout : 出块的时间间隔

MaxMessageCount: 一个块中最大交易数量

AbsoluteMaxBytes: 块的最大大小

PreferredMaxBytes: 块的优先选择的大小




点击引领话题📣 发布并加入讨论🔥
0 评论
0 收藏