mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
Address more review feedback
Use `errors.Is` instead of `errors.As` since we don't need to access special fields in the custom error type. Rather than generating a new error to wrap, just capture the exisitng error.
This commit is contained in:
parent
45dce9d3e1
commit
e191e9f66d
2 changed files with 3 additions and 4 deletions
|
|
@ -88,7 +88,7 @@ type errTxPoolTerminated struct {
|
||||||
|
|
||||||
// Error returns the message from the wrapped error.
|
// Error returns the message from the wrapped error.
|
||||||
func (t *errTxPoolTerminated) Error() string {
|
func (t *errTxPoolTerminated) Error() string {
|
||||||
return t.error.Error()
|
return fmt.Errorf("failed to sync txpool: %w", t.error).Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SimulatedBeacon drives an Ethereum instance as if it were a real beacon
|
// SimulatedBeacon drives an Ethereum instance as if it were a real beacon
|
||||||
|
|
@ -192,7 +192,7 @@ func (c *SimulatedBeacon) sealBlock(withdrawals []*types.Withdrawal, timestamp u
|
||||||
// behavior, the pool will be explicitly blocked on its reset before
|
// behavior, the pool will be explicitly blocked on its reset before
|
||||||
// continuing to the block production below.
|
// continuing to the block production below.
|
||||||
if err := c.eth.APIBackend.TxPool().Sync(); err != nil {
|
if err := c.eth.APIBackend.TxPool().Sync(); err != nil {
|
||||||
return &errTxPoolTerminated{fmt.Errorf("failed to sync txpool: %w", err)}
|
return &errTxPoolTerminated{err}
|
||||||
}
|
}
|
||||||
|
|
||||||
version := payloadVersion(c.eth.BlockChain().Config(), timestamp)
|
version := payloadVersion(c.eth.BlockChain().Config(), timestamp)
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,7 @@ func (a *simulatedBeaconAPI) loop() {
|
||||||
}
|
}
|
||||||
// Avoids spinlooping if the txPool is alredy terminated.
|
// Avoids spinlooping if the txPool is alredy terminated.
|
||||||
if _, err := a.sim.commit(); err != nil {
|
if _, err := a.sim.commit(); err != nil {
|
||||||
var txpTermErr *errTxPoolTerminated
|
if errors.Is(err, &errTxPoolTerminated{}) {
|
||||||
if errors.As(err, &txpTermErr) {
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue