-
Notifications
You must be signed in to change notification settings - Fork 73
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
Clean up controller signals to improve abstraction #1996
Conversation
…d::tuple<signed_block_ptr, block_id_type, account_name>
… signals; remove previously commented signals
signal<void(std::tuple<const signed_block_ptr&, const block_id_type&, const signed_block_header&, uint32_t>)> accepted_block_header; | ||
signal<void(std::tuple<const signed_block_ptr&, const block_id_type&, const signed_block_header&, uint32_t>)> accepted_block; | ||
signal<void(std::tuple<const signed_block_ptr&, const block_id_type&, uint32_t>)> irreversible_block; |
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 would create a type:
using block_signal_params_t = std::tuple<const signed_block_ptr&, const block_id_type&, const signed_block_header&, uint32_t>;
And use the same type for all 3 signals.
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.
Thanks. Will change.
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.
Why signed_block_header
. When is signed_block_header != static_cast<signed_block_header>(*signed_block_ptr)
?
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 no reason for uint32_t
block_num. The user can just use signed_block_ptr->block_num()
. The id is included because calculate_id()
is expensive, but block_num()
I think is efficient enough we don't need to include it in the signal.
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 decided to use signed_block_header
and block_num
explicitly for calling out parameters required by signal clients and for easier review to make sure nothing is missed during the changes. But we need to strike some balances between the number of parameters to signal and abstraction leakage.
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.
Currently
controller
signals an all-purposeblock_state_legacy_ptr
foraccepted_block_header
,accepted_block
,and irreversible_block
.block_state_legacy_ptr
is passed across functions, hiding actual parameters a function needs. Over 40 files depend onblock_state_legacy.hpp
.This PR
block_state_legacy_ptr
and updated implementationpre_accepted_block
,accepted_transaction
, andbad_alloc
.Those changes
block_state_legacy_ptr
by removing the majority uses of it.Resolved #1957