aboutsummaryrefslogtreecommitdiffstats
path: root/node
diff options
context:
space:
mode:
authorFirescar96 <nchinda2@gmail.com>2016-06-25 04:27:55 +0800
committerFirescar96 <nchinda2@gmail.com>2016-07-15 06:51:41 +0800
commit4c3da0f2e1063ccb32933faff4601d5f5e0f987c (patch)
treeeacf53fbbf7f920794ea0ebd13661c90124b262a /node
parente0493457d5a9d280554990b5a29c4fcad69e7d0b (diff)
downloadgo-tangerine-4c3da0f2e1063ccb32933faff4601d5f5e0f987c.tar
go-tangerine-4c3da0f2e1063ccb32933faff4601d5f5e0f987c.tar.gz
go-tangerine-4c3da0f2e1063ccb32933faff4601d5f5e0f987c.tar.bz2
go-tangerine-4c3da0f2e1063ccb32933faff4601d5f5e0f987c.tar.lz
go-tangerine-4c3da0f2e1063ccb32933faff4601d5f5e0f987c.tar.xz
go-tangerine-4c3da0f2e1063ccb32933faff4601d5f5e0f987c.tar.zst
go-tangerine-4c3da0f2e1063ccb32933faff4601d5f5e0f987c.zip
node, p2p, internal: Add ability to remove peers via admin interface
Diffstat (limited to 'node')
-rw-r--r--node/api.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/node/api.go b/node/api.go
index 9b2be9c2e..3523874ab 100644
--- a/node/api.go
+++ b/node/api.go
@@ -58,6 +58,22 @@ func (api *PrivateAdminAPI) AddPeer(url string) (bool, error) {
return true, nil
}
+// RemovePeer disconnects from a a remote node if the connection exists
+func (api *PrivateAdminAPI) RemovePeer(url string) (bool, error) {
+ // Make sure the server is running, fail otherwise
+ server := api.node.Server()
+ if server == nil {
+ return false, ErrNodeStopped
+ }
+ // Try to remove the url as a static peer and return
+ node, err := discover.ParseNode(url)
+ if err != nil {
+ return false, fmt.Errorf("invalid enode: %v", err)
+ }
+ server.RemovePeer(node)
+ return true, nil
+}
+
// StartRPC starts the HTTP RPC API server.
func (api *PrivateAdminAPI) StartRPC(host *string, port *rpc.HexNumber, cors *string, apis *string) (bool, error) {
api.node.lock.Lock()