diff --git a/pkg/network/payload/getblockbyindex.go b/pkg/network/payload/getblockbyindex.go index bd7688abe..450dd4503 100644 --- a/pkg/network/payload/getblockbyindex.go +++ b/pkg/network/payload/getblockbyindex.go @@ -6,9 +6,6 @@ import ( "github.com/nspcc-dev/neo-go/pkg/io" ) -// maximum number of blocks to query about -const maxBlockCount = 500 - // GetBlockByIndex payload type GetBlockByIndex struct { IndexStart uint32 @@ -27,7 +24,7 @@ func NewGetBlockByIndex(indexStart uint32, count uint16) *GetBlockByIndex { func (d *GetBlockByIndex) DecodeBinary(br *io.BinReader) { d.IndexStart = br.ReadU32LE() d.Count = br.ReadU16LE() - if d.Count == 0 || d.Count > maxBlockCount { + if d.Count == 0 || d.Count > MaxHeadersAllowed { br.Err = errors.New("invalid block count") } } diff --git a/pkg/network/payload/getblockbyindex_test.go b/pkg/network/payload/getblockbyindex_test.go index e02dfafa2..1bd2f3452 100644 --- a/pkg/network/payload/getblockbyindex_test.go +++ b/pkg/network/payload/getblockbyindex_test.go @@ -18,7 +18,7 @@ func TestGetBlockDataEncodeDecode(t *testing.T) { require.Error(t, testserdes.DecodeBinary(data, new(GetBlockByIndex))) // invalid block count - d = NewGetBlockByIndex(5, maxBlockCount+1) + d = NewGetBlockByIndex(5, MaxHeadersAllowed+1) data, err = testserdes.EncodeBinary(d) require.NoError(t, err) require.Error(t, testserdes.DecodeBinary(data, new(GetBlockByIndex)))