Skip to content

Commit 906c2d7

Browse files
committed
refactor: add annotation gsl::not_null for ConstructCreditPool
1 parent f1905ca commit 906c2d7

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/evo/creditpool.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ void CCreditPoolManager::AddToCache(const uint256& block_hash, int height, const
112112
}
113113
}
114114

115-
static std::optional<CBlock> GetBlockForCreditPool(const CBlockIndex* const block_index, const Consensus::Params& consensusParams)
115+
static std::optional<CBlock> GetBlockForCreditPool(const gsl::not_null<const CBlockIndex*> block_index,
116+
const Consensus::Params& consensusParams)
116117
{
117118
// There's no CbTx before DIP0003 activation
118119
if (!DeploymentActiveAt(*block_index, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0003)) {
@@ -132,7 +133,8 @@ static std::optional<CBlock> GetBlockForCreditPool(const CBlockIndex* const bloc
132133
return block;
133134
}
134135

135-
CCreditPool CCreditPoolManager::ConstructCreditPool(const CBlockIndex* const block_index, CCreditPool prev, const Consensus::Params& consensusParams)
136+
CCreditPool CCreditPoolManager::ConstructCreditPool(const gsl::not_null<const CBlockIndex*> block_index,
137+
CCreditPool prev, const Consensus::Params& consensusParams)
136138
{
137139
std::optional<CBlock> block = GetBlockForCreditPool(block_index, consensusParams);
138140
if (!block) {
@@ -213,7 +215,7 @@ CCreditPool CCreditPoolManager::ConstructCreditPool(const CBlockIndex* const blo
213215

214216
CCreditPool CCreditPoolManager::GetCreditPool(const CBlockIndex* block_index, const Consensus::Params& consensusParams)
215217
{
216-
std::stack<const CBlockIndex *> to_calculate;
218+
std::stack<gsl::not_null<const CBlockIndex*>> to_calculate;
217219

218220
std::optional<CCreditPool> poolTmp;
219221
while (block_index != nullptr && !(poolTmp = GetFromCache(*block_index)).has_value()) {

src/evo/creditpool.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <evo/assetlocktx.h>
1818

19+
#include <gsl/pointers.h>
1920
#include <optional>
2021
#include <unordered_set>
2122

@@ -134,7 +135,8 @@ class CCreditPoolManager
134135
std::optional<CCreditPool> GetFromCache(const CBlockIndex& block_index);
135136
void AddToCache(const uint256& block_hash, int height, const CCreditPool& pool);
136137

137-
CCreditPool ConstructCreditPool(const CBlockIndex* block_index, CCreditPool prev, const Consensus::Params& consensusParams);
138+
CCreditPool ConstructCreditPool(const gsl::not_null<const CBlockIndex*> block_index, CCreditPool prev,
139+
const Consensus::Params& consensusParams);
138140
};
139141

140142
std::optional<CCreditPoolDiff> GetCreditPoolDiffForBlock(CCreditPoolManager& cpoolman, const BlockManager& blockman, const llmq::CQuorumManager& qman,

0 commit comments

Comments
 (0)