Skip to content

Conversation

@waketraindev
Copy link
Contributor

@waketraindev waketraindev commented Jun 12, 2025

Adds an optional peer_ids parameter to getpeerinfo to filter results by peer IDs.

This is useful when using bitcoin-cli or the console to inspect specific peers referenced in debug.log.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 12, 2025

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32741.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK danielabrozzoni, rkrux

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #34004 (Implementation of SwiftSync by rustaceanrob)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

@0xB10C
Copy link
Contributor

0xB10C commented Jun 13, 2025

I'm frequently using something like bitcoin-cli getpeerinfo | jq '[.[] | select(.id == 24430)]' for this. Doesn't work in the GUI console though.

@waketraindev waketraindev force-pushed the 2025-06-getpeerinfo-filterid branch from 6285d75 to 85f4703 Compare June 13, 2025 12:24
@waketraindev

This comment was marked as off-topic.

@waketraindev waketraindev force-pushed the 2025-06-getpeerinfo-filterid branch from f1f5c11 to 4705d4e Compare June 13, 2025 13:21
@DrahtBot
Copy link
Contributor

🚧 At least one of the CI tasks failed.
Task lint: https://github.com/bitcoin/bitcoin/runs/44049534572
LLM reason (✨ experimental): The CI failure is caused by lint errors, specifically a trailing whitespace issue detected during the lint check.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

@waketraindev waketraindev force-pushed the 2025-06-getpeerinfo-filterid branch 4 times, most recently from a53bd91 to 53c5ce9 Compare June 13, 2025 15:23
@waketraindev waketraindev requested a review from maflcko June 13, 2025 15:26
@waketraindev waketraindev force-pushed the 2025-06-getpeerinfo-filterid branch from 53c5ce9 to af1c1df Compare June 15, 2025 23:21
@waketraindev

This comment was marked as off-topic.

Copy link
Member

@danielabrozzoni danielabrozzoni left a comment

Choose a reason for hiding this comment

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

Concept ACK, I think this is a good addition, as introducing a peer_id parameter to filter the getpeerinfo response is useful for debugging.

This needs a release note :)

Copy link
Contributor

@rkrux rkrux left a comment

Choose a reason for hiding this comment

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

Concept ACK

Useful addition, I can see myself using the filtering here.

As mentioned in #32741 (review), a release note would be helpful as per this: https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#release-notes

@waketraindev waketraindev force-pushed the 2025-06-getpeerinfo-filterid branch 2 times, most recently from 7550c6f to 9393b33 Compare July 4, 2025 12:41
@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 4, 2025

🚧 At least one of the CI tasks failed.
Task lint: https://github.com/bitcoin/bitcoin/runs/45364101888
LLM reason (✨ experimental): Lint check failed due to a coding style error in rpc_net.py caused by an unnecessary semicolon.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

@DrahtBot DrahtBot removed the CI failed label Jul 4, 2025
@waketraindev

This comment was marked as off-topic.

@waketraindev waketraindev changed the title rpc: add optional nodeid param to filter getpeerinfo rpc: add optional peer_id param to filter getpeerinfo Jul 15, 2025
@waketraindev
Copy link
Contributor Author

Rebased on current master.

Copy link
Contributor

@rkrux rkrux left a comment

Choose a reason for hiding this comment

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

crACK 599628ab9c23cd53a30fcbcb5d4ac370bb536547

nonexistent_id = max(p["id"] for p in all_peers) + 1000
assert_equal(node.getpeerinfo(nonexistent_id), [])
assert_raises_rpc_error(-8, "must be a number or an array of numbers", node.getpeerinfo, {})

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit if retouched:

diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py
index 209e804021..47834c8375 100755
--- a/test/functional/rpc_net.py
+++ b/test/functional/rpc_net.py
@@ -200,6 +200,7 @@ class NetTest(BitcoinTestFramework):
         nonexistent_id = max(p["id"] for p in all_peers) + 1000
         assert_equal(node.getpeerinfo(nonexistent_id), [])
         assert_raises_rpc_error(-8, "must be a number or an array of numbers", node.getpeerinfo, {})
+        assert_equal(len(node.getpeerinfo([ids[0], nonexistent_id])), 1)
 
         no_version_peer.peer_disconnect()
         self.wait_until(lambda: len(self.nodes[0].getpeerinfo()) == 2)

@waketraindev waketraindev force-pushed the 2025-06-getpeerinfo-filterid branch from 599628a to 8471074 Compare October 22, 2025 15:20
@waketraindev waketraindev requested a review from rkrux October 24, 2025 14:06
Copy link
Contributor

@rkrux rkrux left a comment

Choose a reason for hiding this comment

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

ACK 8471074

@waketraindev waketraindev changed the title rpc: add optional peer_ids param to filter getpeerinfo rpc: Add optional peer_ids param to filter getpeerinfo Nov 3, 2025
@waketraindev waketraindev force-pushed the 2025-06-getpeerinfo-filterid branch 3 times, most recently from 3e28ffb to e8764d8 Compare November 18, 2025 23:34
@maflcko
Copy link
Member

maflcko commented Nov 19, 2025

the commit message is wrong?

@waketraindev waketraindev force-pushed the 2025-06-getpeerinfo-filterid branch from e8764d8 to 9b6090d Compare November 19, 2025 10:31
@waketraindev
Copy link
Contributor Author

the commit message is wrong?

Thanks. Must've replaced it by mistake when I rebased. Fixed now

Copy link
Member

@danielabrozzoni danielabrozzoni left a comment

Choose a reason for hiding this comment

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

tACK 9b6090d

I left a micro-nit, but I'd say avoid fixing it unless you already need to update, so you don't invalidate the ack :)

"Returns data about each connected network peer as a json array of objects.",
{},
"Returns data about each connected network peer as a json array of objects.\n"
"Optionally filter by peer ids.\n",
Copy link
Member

Choose a reason for hiding this comment

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

nit if retouched: "peer IDs" (so it stays consistent with the rest of the help text)

@DrahtBot DrahtBot requested a review from rkrux December 11, 2025 18:13
Copy link
Contributor

@rkrux rkrux left a comment

Choose a reason for hiding this comment

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

lgtm re-ACK 9b6090d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants