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

Commit

Permalink
KEP-823 Second code cleanup; found unused vars, extraneous white spac…
Browse files Browse the repository at this point in the history
…e, refs not attached to types, const-ed a couple of variables
  • Loading branch information
rnistuk authored and rnistuk committed Jun 14, 2019
1 parent ffb45e6 commit e7e8037
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
3 changes: 1 addition & 2 deletions pbft/operations/pbft_persistent_operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ pbft_persistent_operation::record_request(const bzn_envelope& encoded_request)
LOG(debug) << "ignoring record of request for operation " << bzn::bytes_to_debug_string(this->prefix) << " because we already have one";
break;
case storage_result::value_too_large:
LOG(debug) << "request too large to store: " << encoded_request.SerializeAsString().size() << " bytes, "
<< bzn::bytes_to_debug_string(this->prefix);
LOG(debug) << "request too large to store: " << encoded_request.SerializeAsString().size() << " bytes, " << bzn::bytes_to_debug_string(this->prefix);
break;
default:
throw std::runtime_error("failed to write request for operation " + bzn::bytes_to_debug_string(this->prefix));
Expand Down
12 changes: 6 additions & 6 deletions pbft/pbft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ pbft::maybe_record_request(const pbft_msg &msg, const bzn_envelope &env, const s
assert(env.piggybacked_requests_size()); // we must have at least 1 request
if (this->crypto->hash(env.piggybacked_requests(0)) != msg.request_hash())
{
LOG(info) << "Not recording request because its hash does not match";
LOG(info) << "Not recording request because hashes do not match";
return;
}
op->record_request(env.piggybacked_requests(0));
Expand All @@ -372,7 +372,7 @@ pbft::maybe_record_request(const pbft_msg &msg, const bzn_envelope &env, const s
{
if (this->crypto->hash(msg.request()) != msg.request_hash())
{
LOG(info) << "Not recording request because its hash does not match";
LOG(info) << "Not recording request because hashes do not match";
return;
}
op->record_request(msg.request());
Expand All @@ -393,7 +393,7 @@ pbft::handle_preprepare(const pbft_msg& msg, const bzn_envelope& original_msg)
&& std::get<2>(lookup->second.value()) != msg.request_hash())
{

LOG(debug) << "Rejecting preprepare because I've already accepted a conflicting one \n";
LOG(debug) << "Rejecting preprepare: already accepted a conflicting one";
return;
}
else
Expand Down Expand Up @@ -1443,10 +1443,10 @@ std::map<bzn::hash_t, int>
pbft::map_request_to_hash(const bzn_envelope &env)
{
std::map<bzn::hash_t, int> piggybacked_request_hashes;
for (int i{0}; i<env.piggybacked_requests_size(); ++i)
for (int i{0}; i < env.piggybacked_requests_size(); ++i)
{
bzn_envelope request{env.piggybacked_requests(i)};
auto hash{this->crypto->hash(request)};
const bzn_envelope request{env.piggybacked_requests(i)};
const auto hash{this->crypto->hash(request)};
piggybacked_request_hashes[hash] = i;
}
return piggybacked_request_hashes;
Expand Down
2 changes: 0 additions & 2 deletions pbft/test/pbft_audit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ namespace bzn::test
this->build_pbft();
this->pbft->set_audit_enabled(true);

bzn_envelope dummy_original_msg;
pbft_msg preprepare = pbft_msg(this->preprepare_msg);
preprepare.set_sequence(1);

this->pbft->handle_message(preprepare, this->default_original_msg);

for (const auto& peer : TEST_PEER_LIST)
Expand Down
1 change: 0 additions & 1 deletion pbft/test/pbft_join_leave_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ namespace bzn
}
}
}

return false;
}

Expand Down
7 changes: 3 additions & 4 deletions pbft/test/pbft_viewchange_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ namespace bzn
this->run_transaction_through_primary_times(2, current_sequence);

EXPECT_CALL(*mock_node, send_signed_message(A<const boost::asio::ip::tcp::endpoint&>(), ResultOf(test::is_viewchange, Eq(true))))
.WillRepeatedly(Invoke([&](const auto & /*endpoint*/, auto viewchange_env)
.WillRepeatedly(Invoke([&](const auto& /*endpoint*/, auto viewchange_env)
{
pbft_msg viewchange;
EXPECT_TRUE(viewchange.ParseFromString(viewchange_env->pbft())); // this will be valid.
Expand Down Expand Up @@ -213,13 +213,12 @@ namespace bzn
this->build_pbft();

EXPECT_CALL(*mock_node, send_message_str(_, _))
.WillRepeatedly(Invoke([&](const auto & /*endpoint*/, const auto encoded_message)
.WillRepeatedly(Invoke([&](const auto& /*endpoint*/, const auto encoded_message)
{
bzn_envelope envelope;
envelope.ParseFromString(*encoded_message);


pbft_msg view_change;

view_change.ParseFromString(envelope.pbft());
EXPECT_EQ(PBFT_MSG_VIEWCHANGE, view_change.type());
EXPECT_TRUE(2 == view_change.view());
Expand Down

0 comments on commit e7e8037

Please sign in to comment.