Skip to content
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

Fix emit lib #162

Merged
merged 2 commits into from
May 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1758,17 +1758,18 @@ struct controller_impl {
if (!pbft_enabled) return;

if ( pending_pbft_lib ) {
//this is a temp solution for getting current lib, should not use anywhere else;
auto current_lib = fork_db.get_block_in_current_chain_by_num(head->bft_irreversible_blocknum)->id;
auto current_lib_num = std::max(std::max(head->bft_irreversible_blocknum, head->dpos_irreversible_blocknum), snapshot_head_block);
fork_db.set_bft_irreversible(*pending_pbft_lib);
if (!replaying) {
// emit lib signals to a separate channel, plugins should connect to this channel in order to process libs asap.
auto libs_to_be_emitted = vector<block_state_ptr>{};
auto b = fork_db.get_block(*pending_pbft_lib);
while (b->id != current_lib) {
while (b && b->block_num > current_lib_num) {
libs_to_be_emitted.emplace_back(b);
b = fork_db.get_block(b->prev());
}
while (!libs_to_be_emitted.empty()) {
// emit all libs in ascending order.
emit( self.new_irreversible_block, libs_to_be_emitted.back() );
libs_to_be_emitted.pop_back();
}
Expand Down