mirror of
https://github.com/monero-project/monero.git
synced 2025-07-27 22:05:27 -04:00
Merge pull request #3854
149da42
db_lmdb: enable batch transactions by default (stoffu)34cb6b4
add --regtest and --fixed-difficulty for regression testing (vicsn)9e1403e
update get_info RPC and bump RPC version (vicsn)207b66e
first new functional tests (vicsn)
This commit is contained in:
commit
025187e6c9
27 changed files with 719 additions and 16 deletions
|
@ -330,7 +330,7 @@ uint64_t Blockchain::get_current_blockchain_height() const
|
|||
//------------------------------------------------------------------
|
||||
//FIXME: possibly move this into the constructor, to avoid accidentally
|
||||
// dereferencing a null BlockchainDB pointer
|
||||
bool Blockchain::init(BlockchainDB* db, const network_type nettype, bool offline, const cryptonote::test_options *test_options)
|
||||
bool Blockchain::init(BlockchainDB* db, const network_type nettype, bool offline, const cryptonote::test_options *test_options, difficulty_type fixed_difficulty)
|
||||
{
|
||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||
CRITICAL_REGION_LOCAL(m_tx_pool);
|
||||
|
@ -352,6 +352,7 @@ bool Blockchain::init(BlockchainDB* db, const network_type nettype, bool offline
|
|||
|
||||
m_nettype = test_options != NULL ? FAKECHAIN : nettype;
|
||||
m_offline = offline;
|
||||
m_fixed_difficulty = fixed_difficulty;
|
||||
if (m_hardfork == nullptr)
|
||||
{
|
||||
if (m_nettype == FAKECHAIN || m_nettype == STAGENET)
|
||||
|
@ -795,6 +796,11 @@ bool Blockchain::get_block_by_hash(const crypto::hash &h, block &blk, bool *orph
|
|||
// less blocks than desired if there aren't enough.
|
||||
difficulty_type Blockchain::get_difficulty_for_next_block()
|
||||
{
|
||||
if (m_fixed_difficulty)
|
||||
{
|
||||
return m_db->height() ? m_fixed_difficulty : 1;
|
||||
}
|
||||
|
||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||
|
||||
crypto::hash top_hash = get_tail_id();
|
||||
|
@ -1006,6 +1012,11 @@ bool Blockchain::switch_to_alternative_blockchain(std::list<blocks_ext_by_hash::
|
|||
// an alternate chain.
|
||||
difficulty_type Blockchain::get_next_difficulty_for_alternative_chain(const std::list<blocks_ext_by_hash::iterator>& alt_chain, block_extended_info& bei) const
|
||||
{
|
||||
if (m_fixed_difficulty)
|
||||
{
|
||||
return m_db->height() ? m_fixed_difficulty : 1;
|
||||
}
|
||||
|
||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||
std::vector<uint64_t> timestamps;
|
||||
std::vector<difficulty_type> cumulative_difficulties;
|
||||
|
@ -4405,6 +4416,39 @@ 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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue