Skip to content

Commit

Permalink
jsonrpc: Rescan with server ctx not background ctx
Browse files Browse the repository at this point in the history
Using the server context instead of context.Background means that the
long-lived rescan funcs are able to exit properly when the server is
shutdown and its context is closed.
  • Loading branch information
jholdstock committed Oct 14, 2024
1 parent 05105ec commit 31c2f09
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/rpc/jsonrpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -2038,7 +2038,8 @@ func (s *Server) importPrivKey(ctx context.Context, icmd any) (any, error) {
s.wg.Add(1)
go func() {
defer s.wg.Done()
_ = w.RescanFromHeight(context.Background(), n, scanFrom)
serverCtx := s.httpServer.BaseContext(nil)
_ = w.RescanFromHeight(serverCtx, n, scanFrom)
}()
}

Expand Down Expand Up @@ -2095,7 +2096,8 @@ func (s *Server) importPubKey(ctx context.Context, icmd any) (any, error) {
s.wg.Add(1)
go func() {
defer s.wg.Done()
_ = w.RescanFromHeight(context.Background(), n, scanFrom)
serverCtx := s.httpServer.BaseContext(nil)
_ = w.RescanFromHeight(serverCtx, n, scanFrom)
}()
}

Expand Down Expand Up @@ -2146,7 +2148,8 @@ func (s *Server) importScript(ctx context.Context, icmd any) (any, error) {
s.wg.Add(1)
go func() {
defer s.wg.Done()
_ = w.RescanFromHeight(context.Background(), n, scanFrom)
serverCtx := s.httpServer.BaseContext(nil)
_ = w.RescanFromHeight(serverCtx, n, scanFrom)
}()
}

Expand Down

0 comments on commit 31c2f09

Please sign in to comment.