Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new 'dropnode' RPC command #336

Closed
wants to merge 3 commits into from
Closed

Conversation

Roasbeef
Copy link
Member

@Roasbeef Roasbeef commented Mar 1, 2015

This PR adds new JSON-RPC command: dropnode.

This aims to fix #79 by adding a new command that can disconnect any (inbound or outbound) non-persistent peer.

* Adds a new btcd-extension RPC command: `dropnode`
* `dropnode` can disconnect both inbound and outbound
    peers, unlike `addnode <remove> addr` which only drops
    persistent peers.
case dropNodeMsg:
// Check inbound peers. We pass an empty callback since we don't
// require any additional actions on disconnect for inbound peers.
found := disconnectPeer(state.peers, msg.addr, func(p *peer) {})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest passing nil for the function here and adding a nil check in the disconnectPeer function. This will avoid creating a closure which is much more expensive than a nil check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion, I've changed this fragment to pass a nil function instead.

@dajohi
Copy link
Member

dajohi commented Mar 2, 2015

This PR gets a firm NO from me.

Not in favor of yet another command specific command. The 'addnode' command is already a bad enough name.

I am in favor of making a new 'node' command to control nodes such as:

btcctl node remove ID
btcctl node connect IP [perm|temp]
btcctl node disconnect ID

Then in the future, i'd like a
btcctl node ID debuglevel ...

@Roasbeef
Copy link
Member Author

Roasbeef commented Mar 2, 2015

What do you mean by: "command specific command"? Are you opposed to this PR strictly simply because it introduces a new command? Or do you feel that the feature it provides is not useful?

What if it was altered a bit to introduce a new subcommand under addnode? In this case, what should the new sub-command be named? Since remove already exists as a sub-command, any similar synonym could potentially cause confusion due to redundancy/ambiguity (which is why I created a new command in the first place).

I like your suggestion of introducing a custom, new command giving full control of peer connectivity (persistent vs non, etc.). addnode is pretty much a mess naming, and semantic wise.

EDIT: Will open new PR implementing the command suggested above.

@dajohi
Copy link
Member

dajohi commented Mar 2, 2015

I like the idea. I am solely opposed because of the name. :) I would like to organize new commands into subcommands.

@Roasbeef
Copy link
Member Author

Roasbeef commented Mar 5, 2015

Closing in favor of #341

@Roasbeef Roasbeef closed this Mar 5, 2015
jcvernaleo added a commit to jcvernaleo/btcd that referenced this pull request Sep 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

need new rpc command .. addnode <ip> remove .. does not remove from dns list as well as persistent list
3 participants