admin.stopRPC support added which stops the RPC HTTP listener

This commit is contained in:
Bas van Kervel
2015-04-16 12:56:51 +02:00
parent 205378016f
commit 57f93d25bd
3 changed files with 94 additions and 2 deletions

View File

@ -26,6 +26,7 @@ func (js *jsre) adminBindings() {
admin := t.Object()
admin.Set("suggestPeer", js.suggestPeer)
admin.Set("startRPC", js.startRPC)
admin.Set("stopRPC", js.stopRPC)
admin.Set("nodeInfo", js.nodeInfo)
admin.Set("peers", js.peers)
admin.Set("newAccount", js.newAccount)
@ -141,6 +142,13 @@ func (js *jsre) startRPC(call otto.FunctionCall) otto.Value {
return otto.TrueValue()
}
func (js *jsre) stopRPC(call otto.FunctionCall) otto.Value {
if rpc.Stop() == nil {
return otto.TrueValue()
}
return otto.FalseValue()
}
func (js *jsre) suggestPeer(call otto.FunctionCall) otto.Value {
nodeURL, err := call.Argument(0).ToString()
if err != nil {