AddPeer requests connecting to a remote node, and also maintaining the new connection at all times, even reconnecting if it is lost.
(url string)
| 32 | // AddPeer requests connecting to a remote node, and also maintaining the new |
| 33 | // connection at all times, even reconnecting if it is lost. |
| 34 | func (api *PrivateAdminAPI) AddPeer(url string) (bool, error) { |
| 35 | // Make sure the server is running, fail otherwise |
| 36 | server := api.node.Server() |
| 37 | if server == nil { |
| 38 | return false, ErrNodeStopped |
| 39 | } |
| 40 | // Try to add the url as a static peer and return |
| 41 | node, err := discover.ParseNode(url) |
| 42 | if err != nil { |
| 43 | return false, fmt.Errorf("invalid enode: %v", err) |
| 44 | } |
| 45 | server.AddPeer(node) |
| 46 | return true, nil |
| 47 | } |
| 48 | |
| 49 | // RemovePeer disconnects from a a remote node if the connection exists |
| 50 | func (api *PrivateAdminAPI) RemovePeer(url string) (bool, error) { |