-
Notifications
You must be signed in to change notification settings - Fork 37.7k
refactor: move index class members from protected to private #24150
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
refactor: move index class members from protected to private #24150
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
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.
utACK 732fafc, it makes sense to me to make stuff private instead of protected where possible
commit 7a8d2c0 scripted-diff tACK |
commit 5743fa6 - Approach ACK NIT: since this is a refactor - Can we bring base.h into clang-format compliance? diff --git a/src/index/base.h b/src/index/base.h
index 9c4d67865a..44d87f8556 100644
--- a/src/index/base.h
+++ b/src/index/base.h
@@ -33,7 +33,7 @@ protected:
* A locator is used instead of a simple hash of the chain tip because blocks
* and block index entries may not be flushed to disk until after this database
* is updated.
- */
+ */
class DB : public CDBWrapper
{
public: |
Thanks for reviewing @RandyMcMillan. It isn't part of the changes here but happy to if I have to repush. Edit: done. |
a1fa9ae
to
7785095
Compare
Rebased per Invalidates previous ACKs by @PastaPastaPasta and @RandyMcMillan; mind re-ACKing? |
@PastaPastaPasta and @RandyMcMillan, would you mind re-ACKing here? |
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.
re-utACK
tACK 7785095 tested on
|
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.
ACK 7785095
Agreed on updating them to private
and changing from GetName to GetIndexName seems better to understand it.
7785095
to
ef27869
Compare
ef27869
to
6251ba4
Compare
to improve grepping for a more specific function name. -BEGIN VERIFY SCRIPT- sed -i 's/GetName/GetIndexName/g' ./src/index/* -END VERIFY SCRIPT-
and add doxygen comments
and add doxygen comments, and touch up doxygen indentation on one line per review request
and fix some clang formatting
cff04a7
to
4fdd404
Compare
Rebased (see @PastaPastaPasta, @RandyMcMillan and @brunoerg, mind re-ACKing? Thanks ❤️ |
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.
re-ACK 4fdd404
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.
crACK f5e985b
re-ACK f5e985b |
in the class declaration by access and characteristic for clarity and documentation purposes.
f5e985b
to
3f26a36
Compare
Updated the motivation in the PR description and simplified the last commit by dropping the class-to-struct change, per --- a/src/index/base.h
+++ b/src/index/base.h
@@ -57,8 +57,9 @@ protected:
* and block index entries may not be flushed to disk until after this database
* is updated.
*/
- struct DB : public CDBWrapper
+ class DB : public CDBWrapper
{
+ public:
DB(const fs::path& path, size_t n_cache_size,
bool f_memory = false, bool f_wipe = false, bool f_obfuscate = false); |
@@ -26,14 +26,37 @@ struct IndexSummary { | |||
*/ | |||
class BaseIndex : public CValidationInterface | |||
{ | |||
public: | |||
/// Destructor interrupts sync thread if running and blocks until it exits. | |||
virtual ~BaseIndex(); |
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.
You don't need to mark it virtual, there is a bug and it is destructor of CValidationInterface
should marked as virtual
🐙 This pull request conflicts with the target branch and needs rebase. Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft". |
Are you still working on this? |
Closing this as it has not had any activity in a while. If you are interested in continuing work on this, please leave a comment so that it can be reopened. |
Yes. Might be useful to re-open rather than opening a new one, as there is discussion and some feedback to address. |
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.
Concept ACK
Moved to draft for now. Was reopened 3 months ago to continue work / follow up on discussion, but hasn't been touched. Has needed rebase for 6 months. |
Closing temporarily so that I can re-open it -- am still interested to work on this. |
Simplify the index base and child classes and improve encapsulation and clarity by making fully overridden virtual member functions
private
. In the child classes, this allows having only public and private members. This change also help contributors add virtual functions into the correct section. Also rename theGetName()
getters toGetIndexName()
for clarity and easier grepping/reviewing.Some context:
A base class virtual function doesn't need to be accessible to be overridden, but it can only be
private
if fully overridden, e.g. no inherited base implementation is used by the child classes.References:
https://en.cppreference.com/w/cpp/language/virtual: "Base::vf does not need to be accessible or visible to be overridden. (Base::vf can be declared private, or Base can be inherited using private inheritance.)"
"An implementation member should be protected if it provides an operation or data that a derived class will need to use in its own implementation. Otherwise, implementation members should be private." - C++ Primer (Lippman, Lajoie, Moo)
Herb Sutter in http://www.gotw.ca/publications/mill18.htm: "Make virtual functions private, and only if derived classes need to invoke the base implementation of a virtual function, make the virtual function protected. Prefer to make interfaces non-virtual using the Template pattern."