From 6a93b8075655ea49a5b9dc936b27ede53684622b Mon Sep 17 00:00:00 2001 From: Roy Lee Date: Fri, 12 Aug 2022 02:18:22 -0700 Subject: [PATCH] block: allow cached seralized block to be overritten --- block.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/block.go b/block.go index 844d7a4..7ba0d9d 100644 --- a/block.go +++ b/block.go @@ -69,6 +69,13 @@ func (b *Block) Bytes() ([]byte, error) { return serializedBlock, nil } +// Bytes sets the serialized bytes for the Block. This is equivalent to +// calling Serialize on the underlying wire.MsgBlock, however it caches the +// result so subsequent calls are more efficient. +func (b *Block) SetBytes(data []byte) { + b.serializedBlock = data +} + // BytesNoWitness returns the serialized bytes for the block with transactions // encoded without any witness data. func (b *Block) BytesNoWitness() ([]byte, error) { @@ -90,6 +97,12 @@ func (b *Block) BytesNoWitness() ([]byte, error) { return serializedBlock, nil } +// SetBytesNoWitness sets the serialized bytes for the block with transactions +// encoded without any witness data. +func (b *Block) SetBytesNoWitness(data []byte) { + b.serializedBlockNoWitness = data +} + // Hash returns the block identifier hash for the Block. This is equivalent to // calling BlockHash on the underlying wire.MsgBlock, however it caches the // result so subsequent calls are more efficient.