Bitcoin Forum
May 23, 2024, 11:54:54 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Instructing a node to disconnect from a specific peer via RPC  (Read 1039 times)
statoshi (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 66


View Profile WWW
September 12, 2014, 01:02:18 PM
 #1

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?
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652
Merit: 2217


Chief Scientist


View Profile WWW
September 15, 2014, 12:29:24 PM
 #2

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.

How often do you get the chance to work on a potentially world-changing project?
statoshi (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 66


View Profile WWW
September 15, 2014, 12:33:00 PM
 #3

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!
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!