Reduce allocs in Block.Bytes()

This commit is contained in:
David Hill 2016-11-16 12:40:24 -05:00
parent 9b9ce80a2e
commit f6a0d000db

View file

@ -56,8 +56,8 @@ func (b *Block) Bytes() ([]byte, error) {
}
// Serialize the MsgBlock.
var w bytes.Buffer
err := b.msgBlock.Serialize(&w)
w := bytes.NewBuffer(make([]byte, 0, b.msgBlock.SerializeSize()))
err := b.msgBlock.Serialize(w)
if err != nil {
return nil, err
}