aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/blockchain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cryptonote_core/blockchain.cpp')
-rw-r--r--src/cryptonote_core/blockchain.cpp129
1 files changed, 4 insertions, 125 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 798a73c4f..643c04946 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -41,6 +41,7 @@
#include "cryptonote_basic/cryptonote_boost_serialization.h"
#include "cryptonote_config.h"
#include "cryptonote_basic/miner.h"
+#include "hardforks/hardforks.h"
#include "misc_language.h"
#include "profile_tools.h"
#include "file_io_utils.h"
@@ -83,95 +84,6 @@ DISABLE_VS_WARNINGS(4267)
// used to overestimate the block reward when estimating a per kB to use
#define BLOCK_REWARD_OVERESTIMATE (10 * 1000000000000)
-static const struct {
- uint8_t version;
- uint64_t height;
- uint8_t threshold;
- time_t time;
-} mainnet_hard_forks[] = {
- // version 1 from the start of the blockchain
- { 1, 1, 0, 1341378000 },
-
- // version 2 starts from block 1009827, which is on or around the 20th of March, 2016. Fork time finalised on 2015-09-20. No fork voting occurs for the v2 fork.
- { 2, 1009827, 0, 1442763710 },
-
- // version 3 starts from block 1141317, which is on or around the 24th of September, 2016. Fork time finalised on 2016-03-21.
- { 3, 1141317, 0, 1458558528 },
-
- // version 4 starts from block 1220516, which is on or around the 5th of January, 2017. Fork time finalised on 2016-09-18.
- { 4, 1220516, 0, 1483574400 },
-
- // version 5 starts from block 1288616, which is on or around the 15th of April, 2017. Fork time finalised on 2017-03-14.
- { 5, 1288616, 0, 1489520158 },
-
- // version 6 starts from block 1400000, which is on or around the 16th of September, 2017. Fork time finalised on 2017-08-18.
- { 6, 1400000, 0, 1503046577 },
-
- // version 7 starts from block 1546000, which is on or around the 6th of April, 2018. Fork time finalised on 2018-03-17.
- { 7, 1546000, 0, 1521303150 },
-
- // version 8 starts from block 1685555, which is on or around the 18th of October, 2018. Fork time finalised on 2018-09-02.
- { 8, 1685555, 0, 1535889547 },
-
- // version 9 starts from block 1686275, which is on or around the 19th of October, 2018. Fork time finalised on 2018-09-02.
- { 9, 1686275, 0, 1535889548 },
-
- // version 10 starts from block 1788000, which is on or around the 9th of March, 2019. Fork time finalised on 2019-02-10.
- { 10, 1788000, 0, 1549792439 },
-
- // version 11 starts from block 1788720, which is on or around the 10th of March, 2019. Fork time finalised on 2019-02-15.
- { 11, 1788720, 0, 1550225678 },
-};
-static const uint64_t mainnet_hard_fork_version_1_till = 1009826;
-
-static const struct {
- uint8_t version;
- uint64_t height;
- uint8_t threshold;
- time_t time;
-} testnet_hard_forks[] = {
- // version 1 from the start of the blockchain
- { 1, 1, 0, 1341378000 },
-
- // version 2 starts from block 624634, which is on or around the 23rd of November, 2015. Fork time finalised on 2015-11-20. No fork voting occurs for the v2 fork.
- { 2, 624634, 0, 1445355000 },
-
- // versions 3-5 were passed in rapid succession from September 18th, 2016
- { 3, 800500, 0, 1472415034 },
- { 4, 801219, 0, 1472415035 },
- { 5, 802660, 0, 1472415036 + 86400*180 }, // add 5 months on testnet to shut the update warning up since there's a large gap to v6
-
- { 6, 971400, 0, 1501709789 },
- { 7, 1057027, 0, 1512211236 },
- { 8, 1057058, 0, 1533211200 },
- { 9, 1057778, 0, 1533297600 },
- { 10, 1154318, 0, 1550153694 },
- { 11, 1155038, 0, 1550225678 },
-};
-static const uint64_t testnet_hard_fork_version_1_till = 624633;
-
-static const struct {
- uint8_t version;
- uint64_t height;
- uint8_t threshold;
- time_t time;
-} stagenet_hard_forks[] = {
- // version 1 from the start of the blockchain
- { 1, 1, 0, 1341378000 },
-
- // versions 2-7 in rapid succession from March 13th, 2018
- { 2, 32000, 0, 1521000000 },
- { 3, 33000, 0, 1521120000 },
- { 4, 34000, 0, 1521240000 },
- { 5, 35000, 0, 1521360000 },
- { 6, 36000, 0, 1521480000 },
- { 7, 37000, 0, 1521600000 },
- { 8, 176456, 0, 1537821770 },
- { 9, 177176, 0, 1537821771 },
- { 10, 269000, 0, 1550153694 },
- { 11, 269720, 0, 1550225678 },
-};
-
//------------------------------------------------------------------
Blockchain::Blockchain(tx_memory_pool& tx_pool) :
m_db(), m_tx_pool(tx_pool), m_hardfork(NULL), m_timestamps_and_difficulties_height(0), m_current_block_cumul_weight_limit(0), m_current_block_cumul_weight_median(0),
@@ -403,17 +315,17 @@ bool Blockchain::init(BlockchainDB* db, const network_type nettype, bool offline
}
else if (m_nettype == TESTNET)
{
- for (size_t n = 0; n < sizeof(testnet_hard_forks) / sizeof(testnet_hard_forks[0]); ++n)
+ for (size_t n = 0; n < num_testnet_hard_forks; ++n)
m_hardfork->add_fork(testnet_hard_forks[n].version, testnet_hard_forks[n].height, testnet_hard_forks[n].threshold, testnet_hard_forks[n].time);
}
else if (m_nettype == STAGENET)
{
- for (size_t n = 0; n < sizeof(stagenet_hard_forks) / sizeof(stagenet_hard_forks[0]); ++n)
+ for (size_t n = 0; n < num_stagenet_hard_forks; ++n)
m_hardfork->add_fork(stagenet_hard_forks[n].version, stagenet_hard_forks[n].height, stagenet_hard_forks[n].threshold, stagenet_hard_forks[n].time);
}
else
{
- for (size_t n = 0; n < sizeof(mainnet_hard_forks) / sizeof(mainnet_hard_forks[0]); ++n)
+ for (size_t n = 0; n < num_mainnet_hard_forks; ++n)
m_hardfork->add_fork(mainnet_hard_forks[n].version, mainnet_hard_forks[n].height, mainnet_hard_forks[n].threshold, mainnet_hard_forks[n].time);
}
m_hardfork->init();
@@ -4802,39 +4714,6 @@ HardFork::State Blockchain::get_hard_fork_state() const
return m_hardfork->get_state();
}
-const std::vector<HardFork::Params>& Blockchain::get_hard_fork_heights(network_type nettype)
-{
- static const std::vector<HardFork::Params> mainnet_heights = []()
- {
- std::vector<HardFork::Params> heights;
- for (const auto& i : mainnet_hard_forks)
- heights.emplace_back(i.version, i.height, i.threshold, i.time);
- return heights;
- }();
- static const std::vector<HardFork::Params> testnet_heights = []()
- {
- std::vector<HardFork::Params> heights;
- for (const auto& i : testnet_hard_forks)
- heights.emplace_back(i.version, i.height, i.threshold, i.time);
- return heights;
- }();
- static const std::vector<HardFork::Params> stagenet_heights = []()
- {
- std::vector<HardFork::Params> heights;
- for (const auto& i : stagenet_hard_forks)
- heights.emplace_back(i.version, i.height, i.threshold, i.time);
- return heights;
- }();
- static const std::vector<HardFork::Params> dummy;
- switch (nettype)
- {
- case MAINNET: return mainnet_heights;
- case TESTNET: return testnet_heights;
- case STAGENET: return stagenet_heights;
- default: return dummy;
- }
-}
-
bool Blockchain::get_hard_fork_voting_info(uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint64_t &earliest_height, uint8_t &voting) const
{
return m_hardfork->get_voting_info(version, window, votes, threshold, earliest_height, voting);