Skip to content

Commit e5208d0

Browse files
jakub-freebitblakehhuynh
authored andcommitted
mobile: close node on error (ethereum#25643)
1 parent 1a418e3 commit e5208d0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mobile/geth.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ func NewNode(datadir string, config *NodeConfig) (stack *Node, _ error) {
156156
// Parse the user supplied genesis spec if not mainnet
157157
genesis = new(core.Genesis)
158158
if err := json.Unmarshal([]byte(config.EthereumGenesis), genesis); err != nil {
159+
rawStack.Close()
159160
return nil, fmt.Errorf("invalid genesis spec: %v", err)
160161
}
161162
// If we have the Ropsten testnet, hard code the chain configs too
@@ -196,11 +197,13 @@ func NewNode(datadir string, config *NodeConfig) (stack *Node, _ error) {
196197
ethConf.DatabaseCache = config.EthereumDatabaseCache
197198
lesBackend, err := les.New(rawStack, &ethConf)
198199
if err != nil {
200+
rawStack.Close()
199201
return nil, fmt.Errorf("ethereum init: %v", err)
200202
}
201203
// If netstats reporting is requested, do it
202204
if config.EthereumNetStats != "" {
203205
if err := ethstats.New(rawStack, lesBackend.ApiBackend, lesBackend.Engine(), config.EthereumNetStats); err != nil {
206+
rawStack.Close()
204207
return nil, fmt.Errorf("netstats init: %v", err)
205208
}
206209
}

0 commit comments

Comments
 (0)