wire: reduce allocs in BlockHash()

This commit is contained in:
David Hill 2016-11-16 11:04:47 -05:00 committed by Dave Collins
parent 807d344fe9
commit 187355448a

View file

@ -53,8 +53,8 @@ func (h *BlockHeader) BlockHash() chainhash.Hash {
// transactions. Ignore the error returns since there is no way the
// encode could fail except being out of memory which would cause a
// run-time panic.
var buf bytes.Buffer
_ = writeBlockHeader(&buf, 0, h)
buf := bytes.NewBuffer(make([]byte, 0, MaxBlockHeaderPayload))
_ = writeBlockHeader(buf, 0, h)
return chainhash.DoubleHashH(buf.Bytes())
}