RemovePeer disconnects from a a remote node if the connection exists
(url string)
| 48 | |
| 49 | // RemovePeer disconnects from a a remote node if the connection exists |
| 50 | func (api *PrivateAdminAPI) RemovePeer(url string) (bool, error) { |
| 51 | // Make sure the server is running, fail otherwise |
| 52 | server := api.node.Server() |
| 53 | if server == nil { |
| 54 | return false, ErrNodeStopped |
| 55 | } |
| 56 | // Try to remove the url as a static peer and return |
| 57 | node, err := discover.ParseNode(url) |
| 58 | if err != nil { |
| 59 | return false, fmt.Errorf("invalid enode: %v", err) |
| 60 | } |
| 61 | server.RemovePeer(node) |
| 62 | return true, nil |
| 63 | } |
| 64 | |
| 65 | // PeerEvents creates an RPC subscription which receives peer events from the |
| 66 | // node's p2p.Server |
nothing calls this directly
no test coverage detected