mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 13:41:37 +00:00
block: remove MaxContentsPerBlock
This commit is contained in:
parent
2f490a3403
commit
4df8a2ad36
4 changed files with 7 additions and 9 deletions
|
@ -14,10 +14,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
// MaxContentsPerBlock is the maximum number of contents (transactions + consensus data) per block.
|
||||
MaxContentsPerBlock = math.MaxUint16
|
||||
// MaxTransactionsPerBlock is the maximum number of transactions per block.
|
||||
MaxTransactionsPerBlock = MaxContentsPerBlock
|
||||
MaxTransactionsPerBlock = math.MaxUint16
|
||||
)
|
||||
|
||||
// ErrMaxContentsPerBlock is returned when the maximum number of contents per block is reached.
|
||||
|
@ -88,7 +86,7 @@ func NewBlockFromTrimmedBytes(network netmode.Magic, stateRootEnabled bool, b []
|
|||
block.Script.DecodeBinary(br)
|
||||
|
||||
lenHashes := br.ReadVarUint()
|
||||
if lenHashes > MaxContentsPerBlock {
|
||||
if lenHashes > MaxTransactionsPerBlock {
|
||||
return nil, ErrMaxContentsPerBlock
|
||||
}
|
||||
if lenHashes > 0 {
|
||||
|
@ -140,7 +138,7 @@ func (b *Block) Trim() ([]byte, error) {
|
|||
func (b *Block) DecodeBinary(br *io.BinReader) {
|
||||
b.Base.DecodeBinary(br)
|
||||
contentsCount := br.ReadVarUint()
|
||||
if contentsCount > MaxContentsPerBlock {
|
||||
if contentsCount > MaxTransactionsPerBlock {
|
||||
br.Err = ErrMaxContentsPerBlock
|
||||
return
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ func TestBlockEncodeDecode(t *testing.T) {
|
|||
|
||||
t.Run("bad contents count", func(t *testing.T) {
|
||||
b := newDumbBlock()
|
||||
b.Transactions = make([]*transaction.Transaction, MaxContentsPerBlock+1)
|
||||
b.Transactions = make([]*transaction.Transaction, MaxTransactionsPerBlock+1)
|
||||
for i := range b.Transactions {
|
||||
b.Transactions[i] = &transaction.Transaction{
|
||||
Script: []byte("my_pretty_script"),
|
||||
|
|
|
@ -24,7 +24,7 @@ func (m *MerkleBlock) DecodeBinary(br *io.BinReader) {
|
|||
m.Base.DecodeBinary(br)
|
||||
|
||||
txCount := int(br.ReadVarUint())
|
||||
if txCount > block.MaxContentsPerBlock {
|
||||
if txCount > block.MaxTransactionsPerBlock {
|
||||
br.Err = block.ErrMaxContentsPerBlock
|
||||
return
|
||||
}
|
||||
|
|
|
@ -46,8 +46,8 @@ func TestMerkleBlock_EncodeDecodeBinary(t *testing.T) {
|
|||
_ = b.Hash()
|
||||
expected := &MerkleBlock{
|
||||
Base: b,
|
||||
TxCount: block.MaxContentsPerBlock + 1,
|
||||
Hashes: make([]util.Uint256, block.MaxContentsPerBlock),
|
||||
TxCount: block.MaxTransactionsPerBlock + 1,
|
||||
Hashes: make([]util.Uint256, block.MaxTransactionsPerBlock),
|
||||
Flags: []byte{},
|
||||
}
|
||||
data, err := testserdes.EncodeBinary(expected)
|
||||
|
|
Loading…
Reference in a new issue