use errors.Join

This commit is contained in:
Roberto Bayardo 2024-03-23 11:53:25 -07:00
parent 31a3ae4ccd
commit f160500994
No known key found for this signature in database
GPG key ID: BAD75F1206851CC1

View file

@ -17,6 +17,7 @@
package simulated package simulated
import ( import (
"errors"
"time" "time"
"github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum"
@ -142,18 +143,16 @@ func (n *Backend) Close() error {
n.client.Close() n.client.Close()
n.client = simClient{} n.client = simClient{}
} }
var rerr error // return only last error if there are multiple var err error
if n.beacon != nil { if n.beacon != nil {
rerr = n.beacon.Stop() err = n.beacon.Stop()
n.beacon = nil n.beacon = nil
} }
if n.node != nil { if n.node != nil {
if err := n.node.Close(); err != nil { err = errors.Join(err, n.node.Close())
rerr = err
}
n.node = nil n.node = nil
} }
return rerr return err
} }
// Commit seals a block and moves the chain forward to a new empty block. // Commit seals a block and moves the chain forward to a new empty block.