mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00

* Logger: change log level for "Couldn't find UTXO entry" to debug * ignore error for orphans * continue also if orphans * check if blocks exist * safe rpc mode * limit window size * verify block status depending on context * allow a 2 factor gap in expected mergeset size Co-authored-by: msutton <mikisiton2@gmail.com>
34 lines
1.0 KiB
Go
34 lines
1.0 KiB
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) {
|
|
if context.Config.SafeRPC {
|
|
log.Warn("ShutDown RPC command called while node in safe RPC mode -- ignoring.")
|
|
response := appmessage.NewShutDownResponseMessage()
|
|
response.Error =
|
|
appmessage.RPCErrorf("ShutDown RPC command called while node in safe RPC mode")
|
|
return response, nil
|
|
}
|
|
|
|
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
|
|
}
|