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

doc: Document optional RPC result fields #23652

Closed
wants to merge 2 commits into from

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Dec 2, 2021

No description provided.

Can be reviewed with --ignore-all-space --word-diff-regex=.
@maflcko
Copy link
Member Author

maflcko commented Dec 2, 2021

Needed by itself and for #23083

@laanwj laanwj added the Docs label Dec 2, 2021
@maflcko maflcko changed the title doc: Document optional result fields in getpeerinfo doc: Document optional RPC result fields Dec 2, 2021
Can be reviewed with --ignore-all-space --word-diff-regex=.
Copy link
Contributor

@shaavan shaavan left a comment

Choose a reason for hiding this comment

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

ACK fab6c43

{RPCResult::Type::NUM, "witness_version", /* optional */ true, "The version number of the witness program"},
{RPCResult::Type::STR_HEX, "witness_program", /* optional */ true, "The hex value of the witness program"},
{RPCResult::Type::STR, "error", /* optional */ true, "Error message, if any"},
{RPCResult::Type::ARR, "error_locations", /*optional=*/true, "Indices of likely error locations in address, if known (e.g. Bech32 errors)",
Copy link
Contributor

Choose a reason for hiding this comment

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

I was just curious about this thing. In this section of code, two ways of commenting the argument as optional are used:

  1. /* optional */
  2. /*optional=*/

I have noticed that in this PR, you have used the second way of commenting for all the comments you added and have not changed the preexisting comments.
If the second way of commenting is the right way of the two. Maybe it could be taken up in follow-up PRs to refactor the type 1 comments.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this is being done in #23545

Copy link
Contributor

Choose a reason for hiding this comment

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

this is being done in #23545

That's great! Just have to wait for a little to resolve PR conflicts with #23545

@maflcko
Copy link
Member Author

maflcko commented Dec 3, 2021

Rendered diff:

diff --git a/getpeerinfo b/getpeerinfo
index e7ab8e8..ae40ea4 100644
--- a/getpeerinfo
+++ b/getpeerinfo
@@ -34,16 +34,16 @@ Result:
     "inbound" : true|false,               (boolean) Inbound (true) or Outbound (false)
     "bip152_hb_to" : true|false,          (boolean) Whether we selected peer as (compact blocks) high-bandwidth peer
     "bip152_hb_from" : true|false,        (boolean) Whether peer selected us as (compact blocks) high-bandwidth peer
-    "startingheight" : n,                 (numeric) The starting height (block) of the peer
-    "synced_headers" : n,                 (numeric) The last header we have in common with this peer
-    "synced_blocks" : n,                  (numeric) The last block we have in common with this peer
-    "inflight" : [                        (json array)
+    "startingheight" : n,                 (numeric, optional) The starting height (block) of the peer
+    "synced_headers" : n,                 (numeric, optional) The last header we have in common with this peer
+    "synced_blocks" : n,                  (numeric, optional) The last block we have in common with this peer
+    "inflight" : [                        (json array, optional)
       n,                                  (numeric) The heights of blocks we're currently asking from this peer
       ...
     ],
-    "addr_relay_enabled" : true|false,    (boolean) Whether we participate in address relay with this peer
-    "addr_processed" : n,                 (numeric) The total number of addresses processed, excluding those dropped due to rate limiting
-    "addr_rate_limited" : n,              (numeric) The total number of addresses dropped due to rate limiting
+    "addr_relay_enabled" : true|false,    (boolean, optional) Whether we participate in address relay with this peer
+    "addr_processed" : n,                 (numeric, optional) The total number of addresses processed, excluding those dropped due to rate limiting
+    "addr_rate_limited" : n,              (numeric, optional) The total number of addresses dropped due to rate limiting
     "permissions" : [                     (json array) Any special permissions that have been granted to this peer
       "str",                              (string) bloomfilter (allow requesting BIP37 filtered blocks and transactions),
                                           noban (do not ban for misbehavior; implies download),
diff --git a/validateaddress b/validateaddress
index 90153d0..a02faee 100644
--- a/validateaddress
+++ b/validateaddress
@@ -15,7 +15,7 @@ Result:
   "witness_version" : n,        (numeric, optional) The version number of the witness program
   "witness_program" : "hex",    (string, optional) The hex value of the witness program
   "error" : "str",              (string, optional) Error message, if any
-  "error_locations" : [         (json array) Indices of likely error locations in address, if known (e.g. Bech32 errors)
+  "error_locations" : [         (json array, optional) Indices of likely error locations in address, if known (e.g. Bech32 errors)
     n,                          (numeric) index of a potential error
     ...
   ]

maflcko pushed a commit to bitcoin-core/gui that referenced this pull request Dec 3, 2021
fab6c43 doc: Document optional result fields in validateaddress (MarcoFalke)
faee265 doc: Document optional result fields in getpeerinfo (MarcoFalke)

Pull request description:

ACKs for top commit:
  shaavan:
    ACK fab6c43

Tree-SHA512: 78458d0c4deb9253fbfe37fa5736a7db14eb0478bcc4adeba10ba6945e83d8eac92048293f50c054ea612609939151b4a2e1226c06f6067901f3d58c127c7e18
@fanquake
Copy link
Member

fanquake commented Dec 3, 2021

This was merged.

@fanquake fanquake closed this Dec 3, 2021
@maflcko maflcko deleted the 2112-docOptPeer branch December 3, 2021 09:18
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 3, 2021
Comment on lines +148 to +154
{RPCResult::Type::NUM, "startingheight", /*optional=*/true, "The starting height (block) of the peer"},
{RPCResult::Type::NUM, "synced_headers", /*optional=*/true, "The last header we have in common with this peer"},
{RPCResult::Type::NUM, "synced_blocks", /*optional=*/true, "The last block we have in common with this peer"},
{RPCResult::Type::ARR, "inflight", /*optional=*/true, "",
{
{RPCResult::Type::NUM, "n", "The heights of blocks we're currently asking from this peer"},
}},
Copy link
Member

Choose a reason for hiding this comment

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

When are these not provided? Looks impossible to actually happen? Maybe a rare threading race (should we even document those?)?

Copy link
Member Author

Choose a reason for hiding this comment

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

I am happy to review a pull request that always provides them.

Copy link
Member

Choose a reason for hiding this comment

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

My point is that the current code appears to already always provide them.

Copy link
Member Author

Choose a reason for hiding this comment

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

They are not if fStateStats is false.

Again, if you find a way to remove the fStateStats bool, please ping me for review.

Copy link
Member

Choose a reason for hiding this comment

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

When can it be false?

Copy link
Member Author

Choose a reason for hiding this comment

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

When can it be false?

You answered this in your first comment:

threading race (should we even document those?)?

I'd say yes, not only to clarify the interface, but also to avoid applications from crashing due to unexpected KeyError

Copy link

@alirezaayande alirezaayande left a comment

Choose a reason for hiding this comment

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

.

@bitcoin bitcoin deleted a comment from alirezaayande Dec 10, 2021
@bitcoin bitcoin deleted a comment from alirezaayande Dec 10, 2021
RandyMcMillan pushed a commit to RandyMcMillan/mempool-tab that referenced this pull request Dec 23, 2021
d6995c1 doc: Document optional result fields in validateaddress (MarcoFalke)
807414e doc: Document optional result fields in getpeerinfo (MarcoFalke)

Pull request description:

ACKs for top commit:
  shaavan:
    ACK d6995c1

Tree-SHA512: 78458d0c4deb9253fbfe37fa5736a7db14eb0478bcc4adeba10ba6945e83d8eac92048293f50c054ea612609939151b4a2e1226c06f6067901f3d58c127c7e18
@bitcoin bitcoin locked and limited conversation to collaborators Dec 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants