-
Notifications
You must be signed in to change notification settings - Fork 14
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
Extract p2p::FinalizerCommits component #753
Conversation
Signed-off-by: Stanislav Frolov <[email protected]>
Signed-off-by: Stanislav Frolov <[email protected]>
Signed-off-by: Stanislav Frolov <[email protected]>
Signed-off-by: Stanislav Frolov <[email protected]>
Signed-off-by: Stanislav Frolov <[email protected]>
Signed-off-by: Stanislav Frolov <[email protected]>
Signed-off-by: Stanislav Frolov <[email protected]>
Signed-off-by: Stanislav Frolov <[email protected]>
I for one do not mind either way. Of course it's always nicer to have smaller pieces to review, but if the individual pieces do not make sense. I am mostly just wondering about tests and TODOs. Since it is a component it should be testable as a unit. If it's simpler to have it as part of #744, well then. |
I ported all the fix to the main PR. Feel free to review them #744. |
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 67c5e83
class FinalizerCommitsHandler { | ||
public: | ||
//! \brief Process getcommits message | ||
virtual void OnGetCommits( |
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.
WDYS about Process<message name>
pattern name? Basically, call it ProcessGetCommits
as this is the function which processes getcommits
p2p message. It matches quite well with the existing functions we have e,g. ProcessNewBlock
, with the comment above and is invoked in the net_processing.cpp
file.
For me, OnGetCommits
looks like the event that was produced by ProcessGetCommits
function and other components can subscribe to.
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.
Although this function processes getcommits
message, the component is designed like a handler that responses on network events so that on_<message>
sounds reasonable to me. Also, in python, we use on_<message>
pattern. After all, every function processes something...
But, If others want to rename it to Processes<message>
, I will rename.
} | ||
best_index = index; | ||
|
||
} else if (index->nHeight > best_index->nHeight && m_active_chain->Contains(*index)) { |
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.
&& m_active_chain->Contains(*index)
can be ommited as we get index
from m_active_chain
so it must be there.
|
||
FinalizerCommitsResponse response; | ||
do { | ||
walk = m_active_chain->AtHeight(walk->nHeight + 1); |
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.
nit: CChain
has Next
function, could be used instead of manually computing the height.
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.
It's staking::ActiveChain
component which doesn't have such function. Will extend and update this code.
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef UNITE_P2P_FINALIZER_COMMITS_HANDLER |
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.
Include guards usually end with _H
. Would be good to keep the same pattern as in other files.
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.
Hmm anybody cares about such a "pattern"? Will do!
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef UNITE_P2P_FINALIZER_COMMITS_HANDLER_IMPL |
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.
would be good to add _H
to the include guard to keep the same naming.
|
||
namespace p2p { | ||
|
||
class FinalizerCommitsHandlerImpl : public ::p2p::FinalizerCommitsHandler { |
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 see we put implementation classes directly to the cpp. Then we can hide it even inside the anonymous namespace. What is the reason for exposing FinalizerCommitsHandlerImpl
?
nit: ::p2p::
can be ommited.
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.
The reason is the unit tests.
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.
::p2p::
can be ommited.
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef UNITE_FINALIZATION_P2P | ||
#define UNITE_FINALIZATION_P2P | ||
#ifndef UNITE_P2P_FINALIZER_COMMITS_TYPES |
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.
would be good to add _H
to include guard
I guess we decided to have solid #744 instead of splitting. |
Signed-off-by: Stanislav Frolov [email protected]
This PR extracts basement changes from #744. No logical changes in the code.
src/finalizarion/p2p*
tosrc/p2p/finalizer_commits*
.commits
toFinalizerCommits
in type and file names.FinalizerCommits
.