Skip to content

doc: Add comments to FIELD_* constants in proxy.h#279

Open
ViniciusCestarii wants to merge 1 commit into
bitcoin-core:masterfrom
ViniciusCestarii:doc/field-flags-comments
Open

doc: Add comments to FIELD_* constants in proxy.h#279
ViniciusCestarii wants to merge 1 commit into
bitcoin-core:masterfrom
ViniciusCestarii:doc/field-flags-comments

Conversation

@ViniciusCestarii
Copy link
Copy Markdown
Contributor

Add documentation comments to the five FIELD_* bit flag constants in proxy.h, which were previously undocumented

@DrahtBot
Copy link
Copy Markdown

DrahtBot commented May 26, 2026

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

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #274 (Add nonunix platform support by ryanofsky)

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
Copy Markdown
Collaborator

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review d706480. These comments are helpful but could be misleading in a few ways so I left some recommendations below.

Comment thread include/mp/proxy.h Outdated
Comment on lines +307 to +308
static constexpr int FIELD_IN = 1; //!< Field is read from the Cap'n Proto Params struct (client -> server).
static constexpr int FIELD_OUT = 2; //!< Field is read from the Cap'n Proto Results struct (server -> client).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In commit "doc: Add comments to FIELD_* constants in proxy.h" (d706480)

I think it would be better to say "present" instead of "read". "read" is accurate but these flags are used to decide whether to write fields as well, so "present" reflects the wider context

Comment thread include/mp/proxy.h Outdated
static constexpr int FIELD_OPTIONAL = 4;
static constexpr int FIELD_REQUESTED = 8;
static constexpr int FIELD_BOXED = 16;
static constexpr int FIELD_IN = 1; //!< Field is read from the Cap'n Proto Params struct (client -> server).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In commit "doc: Add comments to FIELD_* constants in proxy.h" (d706480)

I think it would be better to move these comments to the Accessor struct below where they are used, and written as preceding comments (//!) trailing comments (//!<) so there is more space for the descriptions.

Could keep //!< comments here referring to the Accessor struct below though.

Comment thread include/mp/proxy.h Outdated
static constexpr int FIELD_BOXED = 16;
static constexpr int FIELD_IN = 1; //!< Field is read from the Cap'n Proto Params struct (client -> server).
static constexpr int FIELD_OUT = 2; //!< Field is read from the Cap'n Proto Results struct (server -> client).
static constexpr int FIELD_OPTIONAL = 4; //!< Field has a `has<Field>` sibling in the Cap'n Proto schema; value may be absent and presence must be checked via `has()`.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In commit "doc: Add comments to FIELD_* constants in proxy.h" (d706480)

Would replace the word "schema" with "struct" to be more specific. Also has<Field> looks like c++ template syntax which could be confusing. And I'm not sure the "presence must be checked" comment is meaningful because it seems focused on reading the field when the flag controls how the field needs to be written as well as read.

Would suggest something more like "Field has a companion has{Name} boolean field in the Cap'n Proto struct. This used to represent optional primitive values (e.g. C++ std::optional<int>) because Cap'n Proto doesn't allow primitive fields to be unset."

Comment thread include/mp/proxy.h Outdated
static constexpr int FIELD_IN = 1; //!< Field is read from the Cap'n Proto Params struct (client -> server).
static constexpr int FIELD_OUT = 2; //!< Field is read from the Cap'n Proto Results struct (server -> client).
static constexpr int FIELD_OPTIONAL = 4; //!< Field has a `has<Field>` sibling in the Cap'n Proto schema; value may be absent and presence must be checked via `has()`.
static constexpr int FIELD_REQUESTED = 8; //!< Field has a `want<Field>` sibling in the Cap'n Proto Params struct; client opts in to receiving it.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In commit "doc: Add comments to FIELD_* constants in proxy.h" (d706480)

This doesn't really say what the flag is used for. Maybe would write "Results field has a companion want{Name} boolean field in the Params struct. Used for optional output parameters (e.g. C++ int*) and set to true if the caller passed a non-null and wants the result."

Comment thread include/mp/proxy.h Outdated
static constexpr int FIELD_OUT = 2; //!< Field is read from the Cap'n Proto Results struct (server -> client).
static constexpr int FIELD_OPTIONAL = 4; //!< Field has a `has<Field>` sibling in the Cap'n Proto schema; value may be absent and presence must be checked via `has()`.
static constexpr int FIELD_REQUESTED = 8; //!< Field has a `want<Field>` sibling in the Cap'n Proto Params struct; client opts in to receiving it.
static constexpr int FIELD_BOXED = 16; //!< Field is a Cap'n Proto pointer type (struct, list, text, data, interface); value may be absent and presence must be checked via `has()`.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In commit "doc: Add comments to FIELD_* constants in proxy.h" (d706480)

I think absense/presence is not really relevant here. Would suggest something more like "Field is a Cap'n Proto pointer type (struct, list, text, data, interface) as opposed to a primitive type (bool, int, float, enum)."

@ViniciusCestarii ViniciusCestarii force-pushed the doc/field-flags-comments branch from d706480 to e863c6c Compare June 3, 2026 13:30
@ViniciusCestarii
Copy link
Copy Markdown
Contributor Author

Forced-push e863c6c to add suggested changes

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.

3 participants