Skip to content

Commit

Permalink
[FAB-1415] Fix peer crashes at commit time.
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
C0rWin committed Dec 15, 2016
1 parent e0ec9f8 commit 21a1d1b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/committer/noopssinglechain/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ func (d *DeliverService) readUntilClose() {
seqNum := t.Block.Header.Number
block := &common.Block{}
block.Header = t.Block.Header
block.Metadata = t.Block.Metadata

// Copy and initialize peer metadata
putils.CopyBlockMetadata(t.Block, block)
block.Data = &common.BlockData{}
for _, d := range t.Block.Data.Data {
if d != nil {
Expand Down
12 changes: 12 additions & 0 deletions protos/utils/blockutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ func GetBlockFromBlockBytes(blockBytes []byte) (*cb.Block, error) {
return block, err
}

// CopyBlockMetadata copies metadata from one block into another
func CopyBlockMetadata(src *cb.Block, dst *cb.Block) {
dst.Metadata = src.Metadata
if dst.Metadata == nil {
dst.Metadata = &cb.BlockMetadata{Metadata: [][]byte{[]byte{}, []byte{}, []byte{}}}
} else if len(dst.Metadata.Metadata) < int(cb.BlockMetadataIndex_TRANSACTIONS_FILTER+1) {
for i := int(len(dst.Metadata.Metadata)); i <= int(cb.BlockMetadataIndex_TRANSACTIONS_FILTER); i++ {
dst.Metadata.Metadata = append(dst.Metadata.Metadata, []byte{})
}
}
}

// MakeConfigurationBlock creates a mock configuration block for testing in
// various modules. This is a convenient function rather than every test
// implements its own
Expand Down

0 comments on commit 21a1d1b

Please sign in to comment.