mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-28 09:46:50 +00:00

* [NOD-1439] Added Stop command * [NOD-1439] Added comment explaining why we wait before closing the StopChan * [NOD-1439] Warnf -> Warn * [NOD-1439] Rename Stop command to Shut Down * [NOD-1439] Clean up pauseBeforeShutDown * [NOD-1439] Add ShutDownRequestMessage case for toRPCPayload * [NOD-1439] Minor stylistic changes
26 lines
753 B
Go
26 lines
753 B
Go
package rpchandlers
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/kaspanet/kaspad/app/appmessage"
|
|
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
|
|
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
|
|
)
|
|
|
|
const pauseBeforeShutDown = time.Second
|
|
|
|
// HandleShutDown handles the respectively named RPC command
|
|
func HandleShutDown(context *rpccontext.Context, _ *router.Router, _ appmessage.Message) (appmessage.Message, error) {
|
|
log.Warn("ShutDown RPC called.")
|
|
|
|
// Wait a second before shutting down, to allow time to return the response to the caller
|
|
spawn("HandleShutDown-pauseAndShutDown", func() {
|
|
<-time.After(pauseBeforeShutDown)
|
|
close(context.ShutDownChan)
|
|
})
|
|
|
|
response := appmessage.NewShutDownResponseMessage()
|
|
return response, nil
|
|
}
|