Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
clean after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelsavannah committed Nov 28, 2018
1 parent 9f3ff94 commit 8aa5301
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pbft/database_pbft_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ database_pbft_service::apply_operation(const std::shared_ptr<bzn::pbft_operation
}

// store requester session for eventual response...
this->operations_awaiting_result[op->get_session()] = op;
this->operations_awaiting_result[op->get_sequence()] = op;

this->process_awaiting_operations();
}
Expand Down
35 changes: 17 additions & 18 deletions pbft/pbft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,26 @@ pbft::start()

this->service->register_execute_handler(
[weak_this = this->weak_from_this(), fd = this->failure_detector]
(std::shared_ptr<pbft_operation> op)
(std::shared_ptr<pbft_operation> op)
{
fd->request_executed(op->get_request_hash());

if (op->get_sequence() % CHECKPOINT_INTERVAL == 0)
{
auto strong_this = weak_this.lock();
if(strong_this)
{
// tell service to save the next checkpoint after this one
strong_this->service->save_service_state_at(op->get_sequence() + CHECKPOINT_INTERVAL);

fd->request_executed(op->request_hash);

if (op->sequence % CHECKPOINT_INTERVAL == 0)
{
auto strong_this = weak_this.lock();
if(strong_this)
{
// tell service to save the next checkpoint after this one
strong_this->service->save_service_state_at(op->sequence + CHECKPOINT_INTERVAL);

strong_this->checkpoint_reached_locally(op->sequence);
}
else
{
throw std::runtime_error("pbft_service callback failed because pbft does not exist");
}
}
strong_this->checkpoint_reached_locally(op->get_sequence());
}
else
{
throw std::runtime_error("pbft_service callback failed because pbft does not exist");
}
}
}
);

this->failure_detector->register_failure_handler(
Expand Down
4 changes: 2 additions & 2 deletions pbft/test/database_pbft_service_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ TEST(database_pbft_service, test_that_executed_operation_fires_callback_with_ope

bzn::database_pbft_service dps(mock_io_context, mem_storage, mock_crud, TEST_UUID);

auto operation = std::make_shared<bzn::pbft_operation>(0, 1, "somehash", nullptr);
auto operation = std::make_shared<bzn::pbft_memory_operation>(0, 1, "somehash", nullptr);
bool execute_handler_called_with_operation = false;

database_msg msg;
Expand All @@ -110,7 +110,7 @@ TEST(database_pbft_service, test_that_executed_operation_fires_callback_with_ope
dps.register_execute_handler(
[&](const auto& operation_ptr)
{
execute_handler_called_with_operation = operation_ptr->request_hash == "somehash";
execute_handler_called_with_operation = operation_ptr->get_request_hash() == "somehash";
});

dps.apply_operation(operation);
Expand Down

0 comments on commit 8aa5301

Please sign in to comment.