Skip to content

Commit

Permalink
[FAB-1773] Add metadata field for orderer use
Browse files Browse the repository at this point in the history
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 <kostas@christidis.io>
  • Loading branch information
kchristidis committed Jan 20, 2017
1 parent 52e116e commit d5a70d1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
8 changes: 6 additions & 2 deletions protos/common/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ func NewBlock(seqNum uint64, previousHash []byte) *Block {
block.Header.Number = seqNum
block.Header.PreviousHash = previousHash
block.Data = &BlockData{}
block.Metadata = &BlockMetadata{
Metadata: [][]byte{[]byte{}, []byte{}, []byte{}},

var metadataContents [][]byte
for i := 0; i < len(BlockMetadataIndex_name); i++ {
metadataContents = append(metadataContents, []byte{})
}
block.Metadata = &BlockMetadata{Metadata: metadataContents}

return block
}

Expand Down
19 changes: 11 additions & 8 deletions protos/common/common.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion protos/common/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ enum HeaderType {
DELIVER_SEEK_INFO = 5; // Used as the type for Envelope messages submitted to instruct the Deliver API to seek
}

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

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

0 comments on commit d5a70d1

Please sign in to comment.