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

Commit

Permalink
KEP-1012: review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
paularchard committed Feb 1, 2019
1 parent 22c7770 commit cc22032
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 0 additions & 2 deletions pbft/operations/pbft_operation_manager.cpp
Expand Up @@ -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<uint64_t, std::shared_ptr<pbft_operation>> result;
const auto maybe_store = [&](const std::shared_ptr<pbft_operation>& op)
{
Expand All @@ -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);
}
}
Expand Down
9 changes: 6 additions & 3 deletions pbft/operations/pbft_persistent_operation.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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<bzn::storage_base> 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 " <<this->prefix;
}

void
Expand Down
2 changes: 2 additions & 0 deletions pbft/operations/pbft_persistent_operation.hpp
Expand Up @@ -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<bzn::storage_base> storage, size_t );

// constructs operation already in storage
pbft_persistent_operation(std::shared_ptr<bzn::storage_base> 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;
Expand Down

0 comments on commit cc22032

Please sign in to comment.