From 187355448a21cb3c644091a716892888c54845c7 Mon Sep 17 00:00:00 2001 From: David Hill <dhill@mindcry.org> Date: Wed, 16 Nov 2016 11:04:47 -0500 Subject: [PATCH] wire: reduce allocs in BlockHash() --- wire/blockheader.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wire/blockheader.go b/wire/blockheader.go index 39859cd7..ba67ee48 100644 --- a/wire/blockheader.go +++ b/wire/blockheader.go @@ -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()) }