Skip to content

Commit

Permalink
Merge branch 'master' into standalone-db
Browse files Browse the repository at this point in the history
  • Loading branch information
ceyonur committed Oct 16, 2024
2 parents 75c76b0 + 273d3d8 commit 5536d05
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ type VM struct {
ethTxPullGossiper gossip.Gossiper

chainAlias string
// RPC handlers (should be stopped before closing chaindb)
rpcHandlers []interface{ Stop() }
}

// Initialize implements the snowman.ChainVM interface
Expand Down Expand Up @@ -832,6 +834,10 @@ func (vm *VM) Shutdown(context.Context) error {
log.Error("error stopping state syncer", "err", err)
}
close(vm.shutdownChan)
// Stop RPC handlers before eth.Stop which will close the database
for _, handler := range vm.rpcHandlers {
handler.Stop()
}
vm.eth.Stop()
log.Info("Ethereum backend stop completed")
vm.shutdownWg.Wait()
Expand Down Expand Up @@ -1042,6 +1048,7 @@ func (vm *VM) CreateHandlers(context.Context) (map[string]http.Handler, error) {
vm.config.WSCPUMaxStored.Duration,
)

vm.rpcHandlers = append(vm.rpcHandlers, handler)
return apis, nil
}

Expand All @@ -1055,6 +1062,7 @@ func (vm *VM) CreateStaticHandlers(context.Context) (map[string]http.Handler, er
return nil, err
}

vm.rpcHandlers = append(vm.rpcHandlers, handler)
return map[string]http.Handler{
"/rpc": handler,
}, nil
Expand Down

0 comments on commit 5536d05

Please sign in to comment.