-
Notifications
You must be signed in to change notification settings - Fork 247
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
Small farmer refactoring #1782
Small farmer refactoring #1782
Conversation
@@ -92,25 +92,31 @@ impl SectorMetadata { | |||
|
|||
/// Commitment and witness corresponding to the same record | |||
#[derive(Debug, Default, Clone, Encode, Decode)] | |||
pub struct RecordMetadata { | |||
pub(crate) struct RecordMetadata { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you think pub(crate)
for the struct only is enough? Is it somewhere in the rust guidelines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fields and methods were also made private, what do you mean by struct only?
I was just hiding data structures that are internal to subspace-farmer-components
and not exposed in public API. This helps ensuring that when in later PR I'm adding checksums, all users of these data structures are doing checksums the same way consistently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant that by making the struct private you prevent leaking the type outside of the crate and all methods and fields are unaccessible respectively. pub
methods and fields are less noisy than pub(crate)
. But maybe it's considered malpractice by the Rust guideline with a good reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean if you need to make it visible publicly, you use pub
, if only in parent module you use pub(super)
and if only inside of the crate then pub(crate)
. Using pub
when it is not exposed publicly is misleading and also results in data structures not reported as unused after refactoring. So everything that can be private should be private and as private as possible.
…pace#1791 autonomys/subspace#1786 autonomys/subspace#1787 autonomys/subspace#1785 autonomys/subspace#1783 autonomys/subspace#1761 autonomys/subspace#1782 autonomys/subspace#1784 autonomys/subspace#1778 autonomys/subspace#1776 autonomys/subspace#1762 autonomys/subspace#1772 autonomys/subspace#1777 autonomys/subspace#1767 autonomys/subspace#1775 autonomys/subspace#1768 autonomys/subspace#1771 autonomys/subspace#1760 autonomys/subspace#1766 autonomys/subspace#1742 autonomys/subspace#1765 autonomys/subspace#1770 autonomys/subspace#1764
…pace#1791 autonomys/subspace#1786 autonomys/subspace#1787 autonomys/subspace#1785 autonomys/subspace#1783 autonomys/subspace#1761 autonomys/subspace#1782 autonomys/subspace#1784 autonomys/subspace#1778 autonomys/subspace#1776 autonomys/subspace#1762 autonomys/subspace#1772 autonomys/subspace#1777 autonomys/subspace#1767 autonomys/subspace#1775 autonomys/subspace#1768 autonomys/subspace#1771 autonomys/subspace#1760 autonomys/subspace#1766 autonomys/subspace#1742 autonomys/subspace#1765 autonomys/subspace#1770 autonomys/subspace#1764
First commit fixes annoying thing introduced in #1778 where specified farm path must exist before use, now it will be created automatically, but only one level deep to prevent surprising behavior.
Second commit is changes extracted from checksumming branch that tries to improve readability, remove some boilerplate and hide some internals of
subspace-farmer-components
that do not need to be exposed publicly.Ignore whitespace changes, then the diff is quite small.
Code contributor checklist: