From 906c2d79ba31629cd1637326dc0a6670df78746c Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Tue, 10 Dec 2024 15:41:30 +0700 Subject: [PATCH] refactor: add annotation gsl::not_null for ConstructCreditPool --- src/evo/creditpool.cpp | 8 +++++--- src/evo/creditpool.h | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/evo/creditpool.cpp b/src/evo/creditpool.cpp index e1b0bb3756..c16950eba1 100644 --- a/src/evo/creditpool.cpp +++ b/src/evo/creditpool.cpp @@ -112,7 +112,8 @@ void CCreditPoolManager::AddToCache(const uint256& block_hash, int height, const } } -static std::optional GetBlockForCreditPool(const CBlockIndex* const block_index, const Consensus::Params& consensusParams) +static std::optional GetBlockForCreditPool(const gsl::not_null block_index, + const Consensus::Params& consensusParams) { // There's no CbTx before DIP0003 activation if (!DeploymentActiveAt(*block_index, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0003)) { @@ -132,7 +133,8 @@ static std::optional GetBlockForCreditPool(const CBlockIndex* const bloc return block; } -CCreditPool CCreditPoolManager::ConstructCreditPool(const CBlockIndex* const block_index, CCreditPool prev, const Consensus::Params& consensusParams) +CCreditPool CCreditPoolManager::ConstructCreditPool(const gsl::not_null block_index, + CCreditPool prev, const Consensus::Params& consensusParams) { std::optional block = GetBlockForCreditPool(block_index, consensusParams); if (!block) { @@ -213,7 +215,7 @@ CCreditPool CCreditPoolManager::ConstructCreditPool(const CBlockIndex* const blo CCreditPool CCreditPoolManager::GetCreditPool(const CBlockIndex* block_index, const Consensus::Params& consensusParams) { - std::stack to_calculate; + std::stack> to_calculate; std::optional poolTmp; while (block_index != nullptr && !(poolTmp = GetFromCache(*block_index)).has_value()) { diff --git a/src/evo/creditpool.h b/src/evo/creditpool.h index de6f13595b..c27179edaa 100644 --- a/src/evo/creditpool.h +++ b/src/evo/creditpool.h @@ -16,6 +16,7 @@ #include +#include #include #include @@ -134,7 +135,8 @@ private: std::optional GetFromCache(const CBlockIndex& block_index); void AddToCache(const uint256& block_hash, int height, const CCreditPool& pool); - CCreditPool ConstructCreditPool(const CBlockIndex* block_index, CCreditPool prev, const Consensus::Params& consensusParams); + CCreditPool ConstructCreditPool(const gsl::not_null block_index, CCreditPool prev, + const Consensus::Params& consensusParams); }; std::optional GetCreditPoolDiffForBlock(CCreditPoolManager& cpoolman, const BlockManager& blockman, const llmq::CQuorumManager& qman,