From c093f070d3590af1d3dcbc497802746b6b911195 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 30 Aug 2019 10:42:07 +0300 Subject: [PATCH] core: add EncodeBinary() support for the block --- pkg/core/block.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/core/block.go b/pkg/core/block.go index 7744314fd..38d8a9122 100644 --- a/pkg/core/block.go +++ b/pkg/core/block.go @@ -152,5 +152,20 @@ func (b *Block) DecodeBinary(r io.Reader) error { // EncodeBinary encodes the block to the given writer. func (b *Block) EncodeBinary(w io.Writer) error { + err := b.BlockBase.EncodeBinary(w) + if err != nil { + return err + } + bw := util.BinWriter{W: w} + bw.WriteVarUint(uint64(len(b.Transactions))) + if bw.Err != nil { + return err + } + for _, tx := range b.Transactions { + err := tx.EncodeBinary(w) + if err != nil { + return err + } + } return nil }