-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1578 from AntelopeIO/persist_hs_safety_liveness_s…
…tate_WIP IF: Persist hotstuff safety state
- Loading branch information
Showing
12 changed files
with
463 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include <eosio/chain/block_header.hpp> | ||
|
||
#include <eosio/hotstuff/qc_chain.hpp> | ||
|
||
namespace eosio::hotstuff { | ||
|
||
using namespace eosio::chain; | ||
|
||
struct safety_state { | ||
|
||
void set_v_height(const fc::crypto::blslib::bls_public_key& finalizer_key, const eosio::chain::view_number v_height) { | ||
_states[finalizer_key].first = v_height; | ||
} | ||
|
||
void set_b_lock(const fc::crypto::blslib::bls_public_key& finalizer_key, const fc::sha256& b_lock) { | ||
_states[finalizer_key].second = b_lock; | ||
} | ||
|
||
std::pair<eosio::chain::view_number, fc::sha256> get_safety_state(const fc::crypto::blslib::bls_public_key& finalizer_key) const { | ||
auto s = _states.find(finalizer_key); | ||
if (s != _states.end()) return s->second; | ||
else return {}; | ||
} | ||
|
||
eosio::chain::view_number get_v_height(const fc::crypto::blslib::bls_public_key& finalizer_key) const { | ||
auto s = _states.find(finalizer_key); | ||
if (s != _states.end()) return s->second.first; | ||
else return {}; | ||
}; | ||
|
||
fc::sha256 get_b_lock(const fc::crypto::blslib::bls_public_key& finalizer_key) const { | ||
auto s_itr = _states.find(finalizer_key); | ||
if (s_itr != _states.end()) return s_itr->second.second; | ||
else return {}; | ||
}; | ||
|
||
//todo : implement safety state default / sorting | ||
|
||
std::pair<eosio::chain::view_number, fc::sha256> get_safety_state() const { | ||
auto s = _states.begin(); | ||
if (s != _states.end()) return s->second; | ||
else return {}; | ||
} | ||
|
||
eosio::chain::view_number get_v_height() const { | ||
auto s = _states.begin(); | ||
if (s != _states.end()) return s->second.first; | ||
else return {}; | ||
}; | ||
|
||
fc::sha256 get_b_lock() const { | ||
auto s_itr = _states.begin(); | ||
if (s_itr != _states.end()) return s_itr->second.second; | ||
else return {}; | ||
}; | ||
|
||
std::map<fc::crypto::blslib::bls_public_key, std::pair<eosio::chain::view_number, fc::sha256>> _states; | ||
}; | ||
} | ||
|
||
FC_REFLECT(eosio::hotstuff::safety_state, (_states)) |
Oops, something went wrong.