From b0faeffbe11fc478b0ddede5865d461b2c315652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Mon, 26 Feb 2024 08:52:20 +0100 Subject: [PATCH] Minor change --- crypto/txsigner.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/crypto/txsigner.go b/crypto/txsigner.go index 060c8c7ad1..2d43bab9ee 100644 --- a/crypto/txsigner.go +++ b/crypto/txsigner.go @@ -35,21 +35,23 @@ type TxSigner interface { // NewSigner creates a new signer based on currently supported forks func NewSigner(forks chain.ForksInTime, chainID uint64) TxSigner { - var signer TxSigner - if forks.London { - signer = NewLondonSigner(chainID) - } else if forks.Berlin { - signer = NewBerlinSigner(chainID) - } else if forks.EIP155 { - signer = NewEIP155Signer(chainID) - } else if forks.Homestead { - signer = NewHomesteadSigner() - } else { - signer = NewFrontierSigner() + return NewLondonSigner(chainID) + } + + if forks.Berlin { + return NewBerlinSigner(chainID) + } + + if forks.EIP155 { + return NewEIP155Signer(chainID) + } + + if forks.Homestead { + return NewHomesteadSigner() } - return signer + return NewFrontierSigner() } // encodeSignature generates a signature based on the R, S and parity values @@ -61,7 +63,7 @@ func NewSigner(forks chain.ForksInTime, chainID uint64) TxSigner { // the encodeSignature function expects parity of Y coordinate as third input and that is what will be encoded func encodeSignature(r, s, parity *big.Int, isHomestead bool) ([]byte, error) { if !ValidateSignatureValues(parity, r, s, isHomestead) { - return nil, errors.New("signature encoding failed: Invalid transaction signature") + return nil, errors.New("signature encoding failed, because transaction signature is invalid") } signature := make([]byte, 65)