From dd6895b1035754cd0936eab0630d572e8051db68 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 18 Jun 2020 21:51:29 +0300 Subject: [PATCH] native: optimize GAS onPersist for empty blocks There is no need to get a list of validators when there are no transactions in the block. --- pkg/core/native/native_gas.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/core/native/native_gas.go b/pkg/core/native/native_gas.go index 4d76ceac7..2e1e57ada 100644 --- a/pkg/core/native/native_gas.go +++ b/pkg/core/native/native_gas.go @@ -80,6 +80,9 @@ func (g *GAS) Initialize(ic *interop.Context) error { // OnPersist implements Contract interface. func (g *GAS) OnPersist(ic *interop.Context) error { + if len(ic.Block.Transactions) == 0 { + return nil + } for _, tx := range ic.Block.Transactions { absAmount := big.NewInt(int64(tx.SystemFee + tx.NetworkFee)) g.burn(ic, tx.Sender, absAmount)