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

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelsavannah committed Nov 8, 2018
1 parent de52fef commit e33cc64
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 24 deletions.
6 changes: 6 additions & 0 deletions pbft/pbft.cpp
Expand Up @@ -78,6 +78,12 @@ pbft::start()
[weak_this = this->weak_from_this(), fd = this->failure_detector]
(std::shared_ptr<pbft_operation> op)
{
if (!op)
{
// TODO: Get real pbft_operation pointers from pbft_service
LOG(error) << "Ignoring null operation pointer recieved from pbft_service";
}

fd->request_executed(op->request_hash);

if (op->sequence % CHECKPOINT_INTERVAL == 0)
Expand Down
26 changes: 13 additions & 13 deletions pbft/pbft_operation.cpp
Expand Up @@ -18,22 +18,22 @@

using namespace bzn;

pbft_operation::pbft_operation(uint64_t view, uint64_t sequence, bzn::hash_t request_hash, std::shared_ptr<const std::vector<peer_address_t>> peers)
pbft_operation::pbft_operation(uint64_t view, uint64_t sequence, const bzn::hash_t& request_hash, std::shared_ptr<const std::vector<peer_address_t>> peers)
: view(view)
, sequence(sequence)
, request_hash(std::move(request_hash))
, request_hash(request_hash)
, peers(std::move(peers))
{
}

bool
pbft_operation::has_request()
pbft_operation::has_request() const
{
return this->request_saved;
}

const pbft_request&
pbft_operation::get_request()
pbft_operation::get_request() const
{
if (!this->request_saved)
{
Expand All @@ -44,7 +44,7 @@ pbft_operation::get_request()
}

const bzn::encoded_message&
pbft_operation::get_encoded_request()
pbft_operation::get_encoded_request() const
{
if (!this->request_saved)
{
Expand Down Expand Up @@ -76,7 +76,7 @@ pbft_operation::record_preprepare(const bzn_envelope& /*encoded_preprepare*/)
}

bool
pbft_operation::has_preprepare()
pbft_operation::has_preprepare() const
{
return this->preprepare_seen;
}
Expand All @@ -95,7 +95,7 @@ pbft_operation::faulty_nodes_bound() const
}

bool
pbft_operation::is_prepared()
pbft_operation::is_prepared() const
{
return this->has_request() && this->has_preprepare() && this->prepares_seen.size() > 2 * this->faulty_nodes_bound();
}
Expand All @@ -107,7 +107,7 @@ pbft_operation::record_commit(const bzn_envelope& encoded_commit)
}

bool
pbft_operation::is_committed()
pbft_operation::is_committed() const
{
return this->is_prepared() && this->commits_seen.size() > 2 * this->faulty_nodes_bound();
}
Expand Down Expand Up @@ -135,19 +135,19 @@ pbft_operation::end_commit_phase()
}

operation_key_t
pbft_operation::get_operation_key()
pbft_operation::get_operation_key() const
{
return std::tuple<uint64_t, uint64_t, hash_t>(this->view, this->sequence, this->request_hash);
return {this->view, this->sequence, this->request_hash};
}

pbft_operation_state
pbft_operation::get_state()
pbft_operation::get_state() const
{
return this->state;
}

std::string
pbft_operation::debug_string()
pbft_operation::debug_string() const
{
return boost::str(boost::format("(v%1%, s%2%) - %3%") % this->view % this->sequence % this->parsed_request.ShortDebugString());
}
Expand All @@ -159,7 +159,7 @@ pbft_operation::set_session(std::weak_ptr<bzn::session_base> session)
}

std::weak_ptr<bzn::session_base>
pbft_operation::session()
pbft_operation::session() const
{
return this->listener_session;
}
22 changes: 11 additions & 11 deletions pbft/pbft_operation.hpp
Expand Up @@ -39,38 +39,38 @@ namespace bzn
{
public:

pbft_operation(uint64_t view, uint64_t sequence, bzn::hash_t request_hash, std::shared_ptr<const std::vector<peer_address_t>> peers);
pbft_operation(uint64_t view, uint64_t sequence, const bzn::hash_t& request_hash, std::shared_ptr<const std::vector<peer_address_t>> peers);

void set_session(std::weak_ptr<bzn::session_base>);

operation_key_t get_operation_key();
pbft_operation_state get_state();
operation_key_t get_operation_key() const;
pbft_operation_state get_state() const;

void record_preprepare(const bzn_envelope& encoded_preprepare);
bool has_preprepare();
bool has_preprepare() const;

void record_prepare(const bzn_envelope& encoded_prepare);
bool is_prepared();
bool is_prepared() const;

void record_commit(const bzn_envelope& encoded_commit);
bool is_committed();
bool is_committed() const;

void begin_commit_phase();
void end_commit_phase();

std::weak_ptr<bzn::session_base> session();
std::weak_ptr<bzn::session_base> session() const;

const pbft_request& get_request();
const bzn::encoded_message& get_encoded_request();
const pbft_request& get_request() const;
const bzn::encoded_message& get_encoded_request() const;

void record_request(const bzn::encoded_message& encoded_request);
bool has_request();
bool has_request() const;

const uint64_t view;
const uint64_t sequence;
const bzn::hash_t request_hash;

std::string debug_string();
std::string debug_string() const;

size_t faulty_nodes_bound() const;

Expand Down

0 comments on commit e33cc64

Please sign in to comment.