Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: statoshi on September 12, 2014, 01:02:18 PM



Title: Instructing a node to disconnect from a specific peer via RPC
Post by: statoshi on September 12, 2014, 01:02:18 PM
I'm working on a daemon to manage peer connections across multiple nodes but seem to have hit a wall when it comes to instructing a node to disconnect from a peer. I have succeeded in using the 'addnode' command to get my nodes to connect to specific peers, but apparently using the 'remove' option does not force a disconnect from the peer.

Is there any way for me to achieve peer disconnects via the RPC API?

If not, would it make sense for me to submit a pull request to add a 'disconnect' option to the 'addnode' RPC call?


Title: Re: Instructing a node to disconnect from a specific peer via RPC
Post by: Gavin Andresen on September 15, 2014, 12:29:24 PM
I needed that, so hacked together a disconnectpeer RPC call:
  https://github.com/gavinandresen/bitcoin-git/commit/499ae0b3d77e1c41d79f34329d555980676d1f3a

Needs more thorough testing-- I'm not sure if calling CloseSocketDisconnect directly from the RPC thread is the cleanest way of disconnecting a peer.


Title: Re: Instructing a node to disconnect from a specific peer via RPC
Post by: statoshi on September 15, 2014, 12:33:00 PM
Excellent. I added in the functionality over the weekend and the only way that seemed appropriate was to call CloseSocketDisconnect(), but I'm not nearly as familiar with the codebase as you!