diff options
Diffstat (limited to 'src/cryptonote_core/hardfork.h')
-rw-r--r-- | src/cryptonote_core/hardfork.h | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/cryptonote_core/hardfork.h b/src/cryptonote_core/hardfork.h index bdac87f2c..6b98b9fa1 100644 --- a/src/cryptonote_core/hardfork.h +++ b/src/cryptonote_core/hardfork.h @@ -44,9 +44,10 @@ namespace cryptonote Ready, } State; + static const uint64_t DEFAULT_ORIGINAL_VERSION_TILL_HEIGHT = 0; // <= actual height static const time_t DEFAULT_FORKED_TIME = 31557600; // a year in seconds static const time_t DEFAULT_UPDATE_TIME = 31557600 / 2; - static const uint64_t DEFAULT_WINDOW_SIZE = 50; // supermajority window check length + static const uint64_t DEFAULT_WINDOW_SIZE = 10080; // supermajority window check length - a week static const int DEFAULT_THRESHOLD_PERCENT = 80; /** @@ -58,7 +59,7 @@ namespace cryptonote * @param window_size the size of the window in blocks to consider for version voting * @param threshold_percent the size of the majority in percents */ - HardFork(cryptonote::BlockchainDB &db, uint8_t original_version = 1, time_t forked_time = DEFAULT_FORKED_TIME, time_t update_time = DEFAULT_UPDATE_TIME, uint64_t window_size = DEFAULT_WINDOW_SIZE, int threshold_percent = DEFAULT_THRESHOLD_PERCENT); + HardFork(cryptonote::BlockchainDB &db, uint8_t original_version = 1, uint64_t original_version_till_height = DEFAULT_ORIGINAL_VERSION_TILL_HEIGHT, time_t forked_time = DEFAULT_FORKED_TIME, time_t update_time = DEFAULT_UPDATE_TIME, uint64_t window_size = DEFAULT_WINDOW_SIZE, int threshold_percent = DEFAULT_THRESHOLD_PERCENT); /** * @brief add a new hardfork height @@ -182,9 +183,11 @@ namespace cryptonote private: - bool do_check(const cryptonote::block &block) const; + uint8_t get_block_version(uint64_t height) const; + bool do_check(uint8_t version) const; int get_voted_fork_index(uint64_t height) const; - uint8_t get_effective_version(const cryptonote::block &block) const; + uint8_t get_effective_version(uint8_t version) const; + bool add(uint8_t block_version, uint64_t height); private: @@ -196,12 +199,14 @@ namespace cryptonote int threshold_percent; uint8_t original_version; + uint64_t original_version_till_height; - typedef struct { + struct Params { uint8_t version; uint64_t height; time_t time; - } Params; + Params(uint8_t version, uint64_t height, time_t time): version(version), height(height), time(time) {} + }; std::vector<Params> heights; std::deque<uint8_t> versions; /* rolling window of the last N blocks' versions */ |