Skip to content

Commit 94c7a44

Browse files
authored
consensus/parlia: improve performance of func IsSystemTransaction (#2912)
1 parent 8111dd9 commit 94c7a44

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

consensus/parlia/parlia.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -321,18 +321,17 @@ func (p *Parlia) Period() uint64 {
321321
}
322322

323323
func (p *Parlia) IsSystemTransaction(tx *types.Transaction, header *types.Header) (bool, error) {
324-
// deploy a contract
325-
if tx.To() == nil {
324+
if tx.To() == nil || !isToSystemContract(*tx.To()) {
325+
return false, nil
326+
}
327+
if tx.GasPrice().Sign() != 0 {
326328
return false, nil
327329
}
328330
sender, err := types.Sender(p.signer, tx)
329331
if err != nil {
330332
return false, errors.New("UnAuthorized transaction")
331333
}
332-
if sender == header.Coinbase && isToSystemContract(*tx.To()) && tx.GasPrice().Cmp(big.NewInt(0)) == 0 {
333-
return true, nil
334-
}
335-
return false, nil
334+
return sender == header.Coinbase, nil
336335
}
337336

338337
func (p *Parlia) IsSystemContract(to *common.Address) bool {

0 commit comments

Comments
 (0)