From cc2203253d1e449f62568373811e1b30552936ac Mon Sep 17 00:00:00 2001 From: Paul Archard Date: Fri, 1 Feb 2019 11:30:21 -0800 Subject: [PATCH] KEP-1012: review changes --- pbft/operations/pbft_operation_manager.cpp | 2 -- pbft/operations/pbft_persistent_operation.cpp | 9 ++++++--- pbft/operations/pbft_persistent_operation.hpp | 2 ++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pbft/operations/pbft_operation_manager.cpp b/pbft/operations/pbft_operation_manager.cpp index 3d67c4c6..025d46d8 100644 --- a/pbft/operations/pbft_operation_manager.cpp +++ b/pbft/operations/pbft_operation_manager.cpp @@ -105,7 +105,6 @@ pbft_operation_manager::prepared_operations_since(uint64_t sequence) // simpleness with respect to dynamic peering. There cannot be multiple prepared operations with distinct // request hashes because we wouldn't accept the preprepares. - // First, search through the operations we have in memory std::map> result; const auto maybe_store = [&](const std::shared_ptr& op) { @@ -129,7 +128,6 @@ pbft_operation_manager::prepared_operations_since(uint64_t sequence) { if (pair.second->get_sequence() > sequence && pair.second->is_prepared()) { - // This is an inefficient search, but we can fix it if it matters maybe_store(pair.second); } } diff --git a/pbft/operations/pbft_persistent_operation.cpp b/pbft/operations/pbft_persistent_operation.cpp index a7a4903d..60eb8cb7 100644 --- a/pbft/operations/pbft_persistent_operation.cpp +++ b/pbft/operations/pbft_persistent_operation.cpp @@ -46,7 +46,8 @@ pbft_persistent_operation::generate_key(const std::string& prefix, const std::st std::string pbft_persistent_operation::prefix_for_sequence(uint64_t sequence) { - return (boost::format("%020u_") % sequence).str(); + return (boost::format("%020u_") % sequence).str(); // This is an inefficient search, but we can fix it if it matters + } bool @@ -92,13 +93,15 @@ pbft_persistent_operation::pbft_persistent_operation(uint64_t view, uint64_t seq } } +// constructs operation already in storage without re-adding to storage pbft_persistent_operation::pbft_persistent_operation(std::shared_ptr storage, uint64_t view, uint64_t sequence, const bzn::hash_t& request_hash) : pbft_operation(view, sequence, request_hash) - , peers_size(1) // TODO: move peers_size out of operation + , peers_size(1) // TODO: move peers_size out of operation. for now, this allows is_* to succeed if stage is set appropriately , storage(std::move(storage)) , prefix(pbft_persistent_operation::generate_prefix(view, sequence, request_hash)) { - // constructs operation already in storage without adding to storage + assert(this->storage->read(get_uuid(), generate_key(this->prefix, STAGE_KEY))); + LOG(info) << "re-hydrated operation with prefix " <prefix; } void diff --git a/pbft/operations/pbft_persistent_operation.hpp b/pbft/operations/pbft_persistent_operation.hpp index 87ac8eed..b998d3b6 100644 --- a/pbft/operations/pbft_persistent_operation.hpp +++ b/pbft/operations/pbft_persistent_operation.hpp @@ -24,6 +24,8 @@ namespace bzn { public: pbft_persistent_operation(uint64_t view, uint64_t sequence, const bzn::hash_t& request_hash, std::shared_ptr storage, size_t ); + + // constructs operation already in storage pbft_persistent_operation(std::shared_ptr storage, uint64_t view, uint64_t sequence, const bzn::hash_t& request_hash); void record_pbft_msg(const pbft_msg& msg, const bzn_envelope& encoded_msg) override;