MCPcopy Create free account
hub / github.com/CPChain/chain / AddPeer

Method AddPeer

node/api.go:34–47  ·  view source on GitHub ↗

AddPeer requests connecting to a remote node, and also maintaining the new connection at all times, even reconnecting if it is lost.

(url string)

Source from the content-addressed store, hash-verified

32// AddPeer requests connecting to a remote node, and also maintaining the new
33// connection at all times, even reconnecting if it is lost.
34func (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
50func (api *PrivateAdminAPI) RemovePeer(url string) (bool, error) {

Callers

nothing calls this directly

Calls 2

ServerMethod · 0.80
AddPeerMethod · 0.65

Tested by

no test coverage detected