From bb1b249e8a2d2569206c14e3f174d4dd175e20be Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Mon, 9 Apr 2018 15:04:59 +0300 Subject: [PATCH] types: lock block on MakePartSet --- types/block.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/block.go b/types/block.go index da5be2b32..34d2cb85d 100644 --- a/types/block.go +++ b/types/block.go @@ -108,6 +108,12 @@ func (b *Block) Hash() cmn.HexBytes { // MakePartSet returns a PartSet containing parts of a serialized block. // This is the form in which the block is gossipped to peers. func (b *Block) MakePartSet(partSize int) *PartSet { + if b == nil { + return nil + } + b.mtx.Lock() + defer b.mtx.Unlock() + // We prefix the byte length, so that unmarshaling // can easily happen via a reader. bz, err := cdc.MarshalBinary(b)