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
Relay compact block messages prior to full block connection #9375
Changes from 8 commits
8017547
9a0b2f4
8baaba6
180586f
6987219
c802092
9eaec08
5749a85
9eb67f5
c1ae4fc
0df777d
962f7f0
73666ad
02ee4eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
#include <boost/signals2/signal.hpp> | ||
#include <boost/shared_ptr.hpp> | ||
#include <memory> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This include is unnecessary There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should be relying on indirect includes, and this file does directly use shared_ptr. |
||
|
||
class CBlock; | ||
class CBlockIndex; | ||
|
@@ -40,6 +41,7 @@ class CValidationInterface { | |
virtual void BlockChecked(const CBlock&, const CValidationState&) {} | ||
virtual void GetScriptForMining(boost::shared_ptr<CReserveScript>&) {}; | ||
virtual void ResetRequestCount(const uint256 &hash) {}; | ||
virtual void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& block) {}; | ||
friend void ::RegisterValidationInterface(CValidationInterface*); | ||
friend void ::UnregisterValidationInterface(CValidationInterface*); | ||
friend void ::UnregisterAllValidationInterfaces(); | ||
|
@@ -66,6 +68,10 @@ struct CMainSignals { | |
boost::signals2::signal<void (boost::shared_ptr<CReserveScript>&)> ScriptForMining; | ||
/** Notifies listeners that a block has been successfully mined */ | ||
boost::signals2::signal<void (const uint256 &)> BlockFound; | ||
/** | ||
* Notifies listeners that a block which builds directly on our current tip | ||
* has been received and connected to the headers tree, though not validated yet */ | ||
boost::signals2::signal<void (const CBlockIndex *, const std::shared_ptr<const CBlock>&)> NewPoWValidBlock; | ||
}; | ||
|
||
CMainSignals& GetMainSignals(); | ||
|
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, this is non-obvious to a caller. And it's especially bad that one of them relies on the const not actually being const :(
Maybe return an updated index, or null in the case of failure? Or return a pair?
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.
Really? I dont see anything non-obvious here? The caller passes in a reference to a const CBlockIndex*, and the function sets that element to the new CBlockIndex*, ie it is returning a const CBlockIndex*, not editing a CBlockIndex which was passed in.
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.
To avoid the const cast, you could do something like:
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 prefer @ryanofsky's code.
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.
OK, changed.