aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/blockchain.cpp35
-rw-r--r--src/cryptonote_core/blockchain.h2
-rw-r--r--src/cryptonote_core/blockchain_and_pool.h6
-rw-r--r--src/cryptonote_core/tx_pool.h2
4 files changed, 9 insertions, 36 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 8036c84cd..7c9bd9163 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -4615,40 +4615,9 @@ bool Blockchain::update_next_cumulative_weight_limit(uint64_t *long_term_effecti
}
else
{
- const uint64_t block_weight = m_db->get_block_weight(db_height - 1);
+ const uint64_t nblocks = std::min<uint64_t>(m_long_term_block_weights_window, db_height);
+ const uint64_t long_term_median = get_long_term_block_weight_median(db_height - nblocks, nblocks);
- uint64_t long_term_median;
- if (db_height == 1)
- {
- long_term_median = CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5;
- }
- else
- {
- uint64_t nblocks = std::min<uint64_t>(m_long_term_block_weights_window, db_height);
- if (nblocks == db_height)
- --nblocks;
- long_term_median = get_long_term_block_weight_median(db_height - nblocks - 1, nblocks);
- }
-
- m_long_term_effective_median_block_weight = std::max<uint64_t>(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5, long_term_median);
-
- uint64_t short_term_constraint = m_long_term_effective_median_block_weight;
- if (hf_version >= HF_VERSION_2021_SCALING)
- short_term_constraint += m_long_term_effective_median_block_weight * 7 / 10;
- else
- short_term_constraint += m_long_term_effective_median_block_weight * 2 / 5;
- uint64_t long_term_block_weight = std::min<uint64_t>(block_weight, short_term_constraint);
-
- if (db_height == 1)
- {
- long_term_median = long_term_block_weight;
- }
- else
- {
- m_long_term_block_weights_cache_tip_hash = m_db->get_block_hash_from_height(db_height - 1);
- m_long_term_block_weights_cache_rolling_median.insert(long_term_block_weight);
- long_term_median = m_long_term_block_weights_cache_rolling_median.median();
- }
m_long_term_effective_median_block_weight = std::max<uint64_t>(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5, long_term_median);
std::vector<uint64_t> weights;
diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h
index 3ad051fc3..be2848d09 100644
--- a/src/cryptonote_core/blockchain.h
+++ b/src/cryptonote_core/blockchain.h
@@ -1609,6 +1609,6 @@ namespace cryptonote
*/
void send_miner_notifications(uint64_t height, const crypto::hash &seed_hash, const crypto::hash &prev_id, uint64_t already_generated_coins);
- friend class BlockchainAndPool;
+ friend struct BlockchainAndPool;
};
} // namespace cryptonote
diff --git a/src/cryptonote_core/blockchain_and_pool.h b/src/cryptonote_core/blockchain_and_pool.h
index c0f607f64..497342aea 100644
--- a/src/cryptonote_core/blockchain_and_pool.h
+++ b/src/cryptonote_core/blockchain_and_pool.h
@@ -37,6 +37,7 @@
#include "blockchain.h"
#include "tx_pool.h"
+#include "warnings.h"
namespace cryptonote
{
@@ -52,7 +53,10 @@ struct BlockchainAndPool
{
Blockchain blockchain;
tx_memory_pool tx_pool;
-
+
+PUSH_WARNINGS
+DISABLE_GCC_WARNING(uninitialized)
BlockchainAndPool(): blockchain(tx_pool), tx_pool(blockchain) {}
+POP_WARNINGS
};
}
diff --git a/src/cryptonote_core/tx_pool.h b/src/cryptonote_core/tx_pool.h
index 47268efb6..3bb96d3a8 100644
--- a/src/cryptonote_core/tx_pool.h
+++ b/src/cryptonote_core/tx_pool.h
@@ -676,7 +676,7 @@ private:
//! Next timestamp that a DB check for relayable txes is allowed
std::atomic<time_t> m_next_check;
- friend class BlockchainAndPool;
+ friend struct BlockchainAndPool;
};
}