From b5909817e40aba71c7655d492a11508e14ac6a83 Mon Sep 17 00:00:00 2001 From: jholdstock Date: Tue, 5 Sep 2023 15:49:31 +0100 Subject: [PATCH] multi: Rename shutdownCtx to ctx. The more verbose name was helpful in the past when some code was handling more than one context, however that is no longer the case due to refactoring so reverting to the more concise name makes sense. --- cmd/vspd/vspd.go | 6 +++--- webapi/webapi.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/vspd/vspd.go b/cmd/vspd/vspd.go index f362175..5e79927 100644 --- a/cmd/vspd/vspd.go +++ b/cmd/vspd/vspd.go @@ -116,7 +116,7 @@ func (v *vspd) run() int { // Create a context that is cancelled when a shutdown request is received // through an interrupt signal. - shutdownCtx := shutdownListener(v.log) + ctx := shutdownListener(v.log) // Run database integrity checks to ensure all data in database is present // and up-to-date. @@ -151,7 +151,7 @@ func (v *vspd) run() int { MaxVoteChangeRecords: maxVoteChangeRecords, VspdVersion: version.String(), } - err = webapi.Start(shutdownCtx, requestShutdown, &shutdownWg, v.cfg.Listen, v.db, v.cfg.logger("API"), + err = webapi.Start(ctx, requestShutdown, &shutdownWg, v.cfg.Listen, v.db, v.cfg.logger("API"), v.dcrd, v.wallets, apiCfg) if err != nil { v.log.Errorf("Failed to initialize webapi: %v", err) @@ -197,7 +197,7 @@ func (v *vspd) run() int { v.blockConnected() // Handle shutdown request. - case <-shutdownCtx.Done(): + case <-ctx.Done(): shutdownWg.Done() return } diff --git a/webapi/webapi.go b/webapi/webapi.go index e3f30d9..e460abb 100644 --- a/webapi/webapi.go +++ b/webapi/webapi.go @@ -75,7 +75,7 @@ type Server struct { signPubKey ed25519.PublicKey } -func Start(shutdownCtx context.Context, requestShutdown func(), shutdownWg *sync.WaitGroup, +func Start(ctx context.Context, requestShutdown func(), shutdownWg *sync.WaitGroup, listen string, vdb *database.VspDatabase, log slog.Logger, dcrd rpc.DcrdConnect, wallets rpc.WalletConnect, config Config) error { @@ -123,7 +123,7 @@ func Start(shutdownCtx context.Context, requestShutdown func(), shutdownWg *sync // Create TCP listener. var listenConfig net.ListenConfig - listener, err := listenConfig.Listen(shutdownCtx, "tcp", listen) + listener, err := listenConfig.Listen(ctx, "tcp", listen) if err != nil { return err } @@ -139,7 +139,7 @@ func Start(shutdownCtx context.Context, requestShutdown func(), shutdownWg *sync shutdownWg.Add(1) go func() { // Wait until shutdown is signaled before shutting down. - <-shutdownCtx.Done() + <-ctx.Done() log.Debug("Stopping webserver...") // Give the webserver 5 seconds to finish what it is doing. @@ -176,7 +176,7 @@ func Start(shutdownCtx context.Context, requestShutdown func(), shutdownWg *sync go func() { for { select { - case <-shutdownCtx.Done(): + case <-ctx.Done(): shutdownWg.Done() return case <-time.After(refresh):