Skip to content

Commit 29eebb5

Browse files
authored
core: replace the empty fmt.Errorf with errors.New (ethereum#32274)
The `errors.new` function does not require string formatting, so its performance is better than that of `fmt.Errorf`.
1 parent b369a85 commit 29eebb5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

core/blockchain.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ func (bc *BlockChain) initializeHistoryPruning(latest uint64) error {
682682
predefinedPoint := history.PrunePoints[bc.genesisBlock.Hash()]
683683
if predefinedPoint == nil || freezerTail != predefinedPoint.BlockNumber {
684684
log.Error("Chain history database is pruned with unknown configuration", "tail", freezerTail)
685-
return fmt.Errorf("unexpected database tail")
685+
return errors.New("unexpected database tail")
686686
}
687687
bc.historyPrunePoint.Store(predefinedPoint)
688688
return nil
@@ -695,15 +695,15 @@ func (bc *BlockChain) initializeHistoryPruning(latest uint64) error {
695695
// action to happen. So just tell them how to do it.
696696
log.Error(fmt.Sprintf("Chain history mode is configured as %q, but database is not pruned.", bc.cfg.ChainHistoryMode.String()))
697697
log.Error(fmt.Sprintf("Run 'geth prune-history' to prune pre-merge history."))
698-
return fmt.Errorf("history pruning requested via configuration")
698+
return errors.New("history pruning requested via configuration")
699699
}
700700
predefinedPoint := history.PrunePoints[bc.genesisBlock.Hash()]
701701
if predefinedPoint == nil {
702702
log.Error("Chain history pruning is not supported for this network", "genesis", bc.genesisBlock.Hash())
703-
return fmt.Errorf("history pruning requested for unknown network")
703+
return errors.New("history pruning requested for unknown network")
704704
} else if freezerTail > 0 && freezerTail != predefinedPoint.BlockNumber {
705705
log.Error("Chain history database is pruned to unknown block", "tail", freezerTail)
706-
return fmt.Errorf("unexpected database tail")
706+
return errors.New("unexpected database tail")
707707
}
708708
bc.historyPrunePoint.Store(predefinedPoint)
709709
return nil

core/vm/contracts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ func (c *bigModExp) Run(input []byte) ([]byte, error) {
515515
}
516516
// enforce size cap for inputs
517517
if c.eip7823 && max(baseLen, expLen, modLen) > 1024 {
518-
return nil, fmt.Errorf("one or more of base/exponent/modulus length exceeded 1024 bytes")
518+
return nil, errors.New("one or more of base/exponent/modulus length exceeded 1024 bytes")
519519
}
520520
// Retrieve the operands and execute the exponentiation
521521
var (

0 commit comments

Comments
 (0)