Skip to content

Commit d5a70d1

Browse files
committed
[FAB-1773] Add metadata field for orderer use
https://jira.hyperledger.org/browse/FAB-1773 A consensus implementation may need to read the ledger and extract metadata from it during operation (most likely when booting up). As an example, the Kafka-based orderer, should read the offset of the last envelope it placed into a block *and* wrote to the local ledger, and use that value to resume consumption of chain's partition. This changeset: 1. Introduces a metadata field for the described use above 2. Sizes and populates the `Metadata` field of a newly-constructed block appropriately. These changes will be put into use in a follow-up changeset [FAB-1774]. Change-Id: Ib3d7d8f77c1a888ebec5790a144457913b201202 Signed-off-by: Kostas Christidis <[email protected]>
1 parent 52e116e commit d5a70d1

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

protos/common/block.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ func NewBlock(seqNum uint64, previousHash []byte) *Block {
2828
block.Header.Number = seqNum
2929
block.Header.PreviousHash = previousHash
3030
block.Data = &BlockData{}
31-
block.Metadata = &BlockMetadata{
32-
Metadata: [][]byte{[]byte{}, []byte{}, []byte{}},
31+
32+
var metadataContents [][]byte
33+
for i := 0; i < len(BlockMetadataIndex_name); i++ {
34+
metadataContents = append(metadataContents, []byte{})
3335
}
36+
block.Metadata = &BlockMetadata{Metadata: metadataContents}
37+
3438
return block
3539
}
3640

protos/common/common.pb.go

+11-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/common/common.proto

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ enum HeaderType {
4343
DELIVER_SEEK_INFO = 5; // Used as the type for Envelope messages submitted to instruct the Deliver API to seek
4444
}
4545

46-
// This enum enlist indexes of the block metadata array
46+
// This enum enlists indexes of the block metadata array
4747
enum BlockMetadataIndex {
4848
SIGNATURES = 0; // Block metadata array position for block signatures
4949
LAST_CONFIGURATION = 1; // Block metadata array poistion to store last configuration block sequence number
5050
TRANSACTIONS_FILTER = 2; // Block metadata array poistion to store serialized bit array filter of invalid transactions
51+
ORDERER = 3; // Block metadata array position to store operational metadata for orderers
52+
// e.g. For Kafka, this is where we store the last offset written to the local ledger.
5153
}
5254

5355
// LastConfiguration is the encoded value for the Metadata message which is encoded in the LAST_CONFIGURATION block metadata index

0 commit comments

Comments
 (0)