Skip to content

Refer to top-level persistence namespaces as primary_namespace #2612

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

Merged
merged 5 commits into from
Sep 28, 2023

Conversation

TheBlueMatt
Copy link
Collaborator

This fixes a bindings build error as namespace is a C++ keyword
which cannot be used as an argument, and while this could be fixed
in the bindings rather than here, separating the term namespace
between the concept (which refers to the primary and sub
namespaces) and the primary namespace makes the documentation more
readable.

Personally I've always found the overload of a prelude enum to be
confusing, and never bothered to handle it properly in bindings as
a result. To avoid needing to do so now, we simply move the
newly-introduced `io::Result` usages over to
`Result<_, io::Error>`.
This fixes a bindings build error as `namespace` is a C++ keyword
which cannot be used as an argument, and while this could be fixed
in the bindings rather than here, separating the term `namespace`
between the concept (which refers to the primary and sub
namespaces) and the primary namespace makes the documentation more
readable.
@TheBlueMatt TheBlueMatt added this to the 0.0.117 milestone Sep 28, 2023
@codecov-commenter
Copy link

codecov-commenter commented Sep 28, 2023

Codecov Report

Attention: 39 lines in your changes are missing coverage. Please review.

Comparison is base (7b4fb9d) 88.98% compared to head (47e1148) 89.00%.
Report is 7 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2612      +/-   ##
==========================================
+ Coverage   88.98%   89.00%   +0.02%     
==========================================
  Files         113      113              
  Lines       86291    86872     +581     
  Branches    86291    86872     +581     
==========================================
+ Hits        76787    77323     +536     
- Misses       7267     7296      +29     
- Partials     2237     2253      +16     
Files Coverage Δ
lightning-persister/src/test_utils.rs 100.00% <100.00%> (ø)
lightning/src/util/test_utils.rs 76.94% <93.75%> (ø)
lightning/src/util/persist.rs 82.94% <94.59%> (ø)
lightning-background-processor/src/lib.rs 86.39% <57.14%> (+0.12%) ⬆️
lightning-persister/src/fs_store.rs 80.13% <26.31%> (ø)
lightning-persister/src/utils.rs 49.01% <36.00%> (+2.08%) ⬆️

... and 11 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tnull tnull self-requested a review September 28, 2023 10:09
Copy link
Contributor

@G8XSU G8XSU left a comment

Choose a reason for hiding this comment

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

There are many more occurrences but we can fix them separately and unblock bindings gen.

Does it work with current changes?

@G8XSU
Copy link
Contributor

G8XSU commented Sep 28, 2023

Mainly in lightning-persister crate, fs_store & utils.rs docs etc.

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

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

There are many occurences of sub_namespace/sub-namespace left in lightning-background-processor, test_utils.rs, fs_store, etc.

@TheBlueMatt
Copy link
Collaborator Author

Does it work with current changes?

Yes, only the trait method variable names get copied, internal code or trait implementations don't matter. I'll fix them all though.

@TheBlueMatt
Copy link
Collaborator Author

Done, I think.

@TheBlueMatt TheBlueMatt force-pushed the 2023-09-namespace-split branch from 738c6f9 to 623a9ce Compare September 28, 2023 17:57
@TheBlueMatt TheBlueMatt force-pushed the 2023-09-namespace-split branch from 623a9ce to f704f2e Compare September 28, 2023 18:25
/// The sub-namespace under which the [`ChannelManager`] will be persisted.
pub const CHANNEL_MANAGER_PERSISTENCE_SUB_NAMESPACE: &str = "";
/// The primary namespace under which the [`ChannelManager`] will be persisted.
pub const CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE: &str = "";
Copy link
Contributor

Choose a reason for hiding this comment

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

femtonit: These names are getting kinda long. Maybe we don't need PERSISTENCE in these constants at all, given that they're defined in persist.rs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, granted PERSISTENCE is a bit long, but still nice to have something in the const name that expresses what they are about, in particular as they may be used in contexts more or less unrelated to persistence . No strong opinion either way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Eh, they're exposed, and in bindings we don't get modules (cause most languages dont have them) so its kinda nice to have them be fully qualified.

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

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

Not gonna nit about the >100 width lines (when rustfmt :P).

Feel free to squash.

@G8XSU
Copy link
Contributor

G8XSU commented Sep 28, 2023

LGTM!

With the top-level namespace now called "primary", "secondary"
makes more sense than "sub".
Update various variables, error strings, and the pending changelog
entry to refer to new namespace terminology.
@TheBlueMatt TheBlueMatt force-pushed the 2023-09-namespace-split branch from f704f2e to 47e1148 Compare September 28, 2023 18:35
@TheBlueMatt
Copy link
Collaborator Author

TheBlueMatt commented Sep 28, 2023

Squashed with one more 100-char fix:

$ git diff-tree -U1 f704f2e7 47e11482
diff --git a/lightning/src/util/persist.rs b/lightning/src/util/persist.rs
index 08039ffc3..2a022c37c 100644
--- a/lightning/src/util/persist.rs
+++ b/lightning/src/util/persist.rs
@@ -105,4 +105,4 @@ pub trait KVStore {
 	///
-	/// Will create the given `primary_namespace` and `secondary_namespace` if not already present in the
-	/// store.
+	/// Will create the given `primary_namespace` and `secondary_namespace` if not already present
+	/// in the store.
 	fn write(&self, primary_namespace: &str, secondary_namespace: &str, key: &str, buf: &[u8]) -> Result<(), io::Error>;

@TheBlueMatt TheBlueMatt merged commit 082a19b into lightningdevkit:main Sep 28, 2023
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.

7 participants