Skip to content

Commit 21a1d1b

Browse files
committed
[FAB-1415] Fix peer crashes at commit time.
Since block comes from the order with meta data position underlined for filter bit array which indicates invalid transactions. This commit takes care and initialize and copies metadata information from block comming out of ordering service. Change-Id: Ifd776748e351ee57a8f680c1468caa03ee02b0ae Signed-off-by: Artem Barger <[email protected]>
1 parent e0ec9f8 commit 21a1d1b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

core/committer/noopssinglechain/client.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ func (d *DeliverService) readUntilClose() {
257257
seqNum := t.Block.Header.Number
258258
block := &common.Block{}
259259
block.Header = t.Block.Header
260-
block.Metadata = t.Block.Metadata
260+
261+
// Copy and initialize peer metadata
262+
putils.CopyBlockMetadata(t.Block, block)
261263
block.Data = &common.BlockData{}
262264
for _, d := range t.Block.Data.Data {
263265
if d != nil {

protos/utils/blockutils.go

+12
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ func GetBlockFromBlockBytes(blockBytes []byte) (*cb.Block, error) {
5252
return block, err
5353
}
5454

55+
// CopyBlockMetadata copies metadata from one block into another
56+
func CopyBlockMetadata(src *cb.Block, dst *cb.Block) {
57+
dst.Metadata = src.Metadata
58+
if dst.Metadata == nil {
59+
dst.Metadata = &cb.BlockMetadata{Metadata: [][]byte{[]byte{}, []byte{}, []byte{}}}
60+
} else if len(dst.Metadata.Metadata) < int(cb.BlockMetadataIndex_TRANSACTIONS_FILTER+1) {
61+
for i := int(len(dst.Metadata.Metadata)); i <= int(cb.BlockMetadataIndex_TRANSACTIONS_FILTER); i++ {
62+
dst.Metadata.Metadata = append(dst.Metadata.Metadata, []byte{})
63+
}
64+
}
65+
}
66+
5567
// MakeConfigurationBlock creates a mock configuration block for testing in
5668
// various modules. This is a convenient function rather than every test
5769
// implements its own

0 commit comments

Comments
 (0)