Bitcoin Forum
May 07, 2024, 05:43:33 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?
1715103813
Hero Member
*
Offline Offline

Posts: 1715103813

View Profile Personal Message (Offline)

Ignore
1715103813
Reply with quote  #2

1715103813
Report to moderator
1715103813
Hero Member
*
Offline Offline

Posts: 1715103813

View Profile Personal Message (Offline)

Ignore
1715103813
Reply with quote  #2

1715103813
Report to moderator
There are several different types of Bitcoin clients. The most secure are full nodes like Bitcoin Core, which will follow the rules of the network no matter what miners do. Even if every miner decided to create 1000 bitcoins per block, full nodes would stick to the rules and reject those blocks.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715103813
Hero Member
*
Offline Offline

Posts: 1715103813

View Profile Personal Message (Offline)

Ignore
1715103813
Reply with quote  #2

1715103813
Report to moderator
1715103813
Hero Member
*
Offline Offline

Posts: 1715103813

View Profile Personal Message (Offline)

Ignore
1715103813
Reply with quote  #2

1715103813
Report to moderator
1715103813
Hero Member
*
Offline Offline

Posts: 1715103813

View Profile Personal Message (Offline)

Ignore
1715103813
Reply with quote  #2

1715103813
Report to moderator
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652
Merit: 2216


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!