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.
This commit is contained in:
jholdstock 2023-09-05 15:49:31 +01:00 committed by Jamie Holdstock
parent 8df00752c0
commit b5909817e4
2 changed files with 7 additions and 7 deletions

View File

@ -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
}

View File

@ -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):