From 0002b652381f652f5eca0262712aad582cb44501 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 18 Jun 2020 10:40:23 +0300 Subject: [PATCH] block: it's not a padding, but a witness count in the base At least that's the interpretation C# codebase has, so be a bit more correct in error message. --- pkg/core/block/block_base.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/core/block/block_base.go b/pkg/core/block/block_base.go index ff71af997..11caa2351 100644 --- a/pkg/core/block/block_base.go +++ b/pkg/core/block/block_base.go @@ -3,7 +3,6 @@ package block import ( "encoding/json" "errors" - "fmt" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/crypto/hash" @@ -84,11 +83,9 @@ func (b *Base) VerificationHash() util.Uint256 { // DecodeBinary implements Serializable interface. func (b *Base) DecodeBinary(br *io.BinReader) { b.decodeHashableFields(br) - - padding := []byte{0} - br.ReadBytes(padding) - if padding[0] != 1 { - br.Err = fmt.Errorf("format error: padding must equal 1 got %d", padding) + witnessCount := br.ReadVarUint() + if br.Err == nil && witnessCount != 1 { + br.Err = errors.New("wrong witness count") return } @@ -98,7 +95,7 @@ func (b *Base) DecodeBinary(br *io.BinReader) { // EncodeBinary implements Serializable interface func (b *Base) EncodeBinary(bw *io.BinWriter) { b.encodeHashableFields(bw) - bw.WriteBytes([]byte{1}) + bw.WriteVarUint(1) b.Script.EncodeBinary(bw) }