From b433d11334f7a71539b6e08f2a2af0f786b82391 Mon Sep 17 00:00:00 2001 From: rnistuk Date: Thu, 20 Jun 2019 14:19:20 -0700 Subject: [PATCH] KEP-823 Adding Isabel's final fixes to clean up maybe_record_request and remove some duplication --- pbft/pbft.cpp | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/pbft/pbft.cpp b/pbft/pbft.cpp index e294d12f..cf87db0f 100644 --- a/pbft/pbft.cpp +++ b/pbft/pbft.cpp @@ -353,27 +353,10 @@ pbft::forward_request_to_primary(const bzn_envelope& request_env) } - -//void -//pbft::maybe_record_internal_request(const bzn_envelope &request_env, const std::shared_ptr &op) -//{ -// pbft_msg msg; -// msg.ParseFromString(request_env.pbft()); -// -// if (this->crypto->hash(request_env) != msg.request_hash()) -// { -// LOG(info) << "Not recording request because hashes do not match"; -// return; -// } -// op->record_request(request_env); -// -//} - - void pbft::maybe_record_request(const bzn_envelope &request_env, const std::shared_ptr &op) { - if (request_env.payload_case() != bzn_envelope::PayloadCase::PAYLOAD_NOT_SET && this->crypto->hash(request_env) != op->get_request_hash()) + if (request_env.payload_case() == bzn_envelope::PayloadCase::PAYLOAD_NOT_SET || this->crypto->hash(request_env) != op->get_request_hash()) { LOG(info) << "Not recording request because hashes do not match"; return; @@ -762,7 +745,7 @@ pbft::do_prepared(const std::shared_ptr& op) void pbft::do_committed(const std::shared_ptr& op) { - LOG(debug) << "Operation " << op->get_sequence() << " is committed-local"; + LOG(debug) << "Operation " << op->get_sequence() << " " << bzn::bytes_to_debug_string(op->get_request_hash()) << " is committed-local"; op->advance_operation_stage(pbft_operation_stage::execute); // If we have a pending session for this request, attach to the operation just before we pass off to the service. @@ -775,6 +758,7 @@ pbft::do_committed(const std::shared_ptr& op) const auto session = this->sessions_waiting_on_forwarded_requests.find(op->get_request_hash()); if (session != this->sessions_waiting_on_forwarded_requests.end() && !op->has_session()) { + LOG(debug) << "Found pending session for this operation"; op->set_session(session->second); } @@ -1958,6 +1942,7 @@ void pbft::add_session_to_sessions_waiting(const std::string& msg_hash, std::sha { if (session) { + LOG(debug) << "Holding session for request " << bzn::bytes_to_debug_string(msg_hash); this->sessions_waiting_on_forwarded_requests[msg_hash] = session; session->add_shutdown_handler([msg_hash, this, session]() {