Skip to content

Commit

Permalink
[FAB-6634] Filtered block should include type
Browse files Browse the repository at this point in the history
This CR adds the block type (e.g. Config, Endorser_Transaction) to
the filtered block.

Change-Id: Iea60502c8fcda30a4811bf556a8dc09db76de922
Signed-off-by: Will Lahti <[email protected]>
  • Loading branch information
wlahti committed Oct 23, 2017
1 parent 2c89bb8 commit b183fce
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 57 deletions.
6 changes: 5 additions & 1 deletion events/producer/eventhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func CreateBlockEvents(block *common.Block) (bevent *pb.Event, fbevent *pb.Event
blockForEvent := &common.Block{}
filteredBlockForEvent := &pb.FilteredBlock{}
filteredTxArray := []*pb.FilteredTransaction{}
var headerType common.HeaderType
blockForEvent.Header = block.Header
blockForEvent.Metadata = block.Metadata
blockForEvent.Data = &common.BlockData{}
Expand All @@ -56,9 +57,11 @@ func CreateBlockEvents(block *common.Block) (bevent *pb.Event, fbevent *pb.Event
if err != nil {
return nil, nil, "", err
}

channelID = chdr.ChannelId
headerType = common.HeaderType(chdr.Type)

if common.HeaderType(chdr.Type) == common.HeaderType_ENDORSER_TRANSACTION {
if headerType == common.HeaderType_ENDORSER_TRANSACTION {
logger.Debugf("Channel [%s]: Block event for block number [%d] contains transaction id: %s", channelID, block.Header.Number, chdr.TxId)
tx, err := utils.GetTransaction(payload.Data)
if err != nil {
Expand Down Expand Up @@ -133,6 +136,7 @@ func CreateBlockEvents(block *common.Block) (bevent *pb.Event, fbevent *pb.Event
}
filteredBlockForEvent.ChannelId = channelID
filteredBlockForEvent.Number = block.Header.Number
filteredBlockForEvent.Type = headerType
filteredBlockForEvent.FilteredTx = filteredTxArray

return CreateBlockEvent(blockForEvent), CreateFilteredBlockEvent(filteredBlockForEvent), channelID, nil
Expand Down
119 changes: 64 additions & 55 deletions protos/peer/events.pb.go

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

3 changes: 2 additions & 1 deletion protos/peer/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ message Unregister {
message FilteredBlock {
string channel_id = 1;
uint64 number = 2; // The position in the blockchain
repeated FilteredTransaction filtered_tx = 3;
common.HeaderType type = 3;
repeated FilteredTransaction filtered_tx = 4;
}

//FilteredTransaction is a minimal set of information about a transaction
Expand Down

0 comments on commit b183fce

Please sign in to comment.