Skip to content

Commit

Permalink
refactor: add annotation gsl::not_null for ConstructCreditPool
Browse files Browse the repository at this point in the history
  • Loading branch information
knst committed Dec 10, 2024
1 parent f1905ca commit bb82af5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/evo/creditpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ static std::optional<CBlock> 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<const CBlockIndex*> block_index,
CCreditPool prev, const Consensus::Params& consensusParams)
{
std::optional<CBlock> block = GetBlockForCreditPool(block_index, consensusParams);
if (!block) {
Expand Down Expand Up @@ -213,7 +214,7 @@ CCreditPool CCreditPoolManager::ConstructCreditPool(const CBlockIndex* const blo

CCreditPool CCreditPoolManager::GetCreditPool(const CBlockIndex* block_index, const Consensus::Params& consensusParams)
{
std::stack<const CBlockIndex *> to_calculate;
std::stack<gsl::not_null<const CBlockIndex*>> to_calculate;

std::optional<CCreditPool> poolTmp;
while (block_index != nullptr && !(poolTmp = GetFromCache(*block_index)).has_value()) {
Expand Down
4 changes: 3 additions & 1 deletion src/evo/creditpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <evo/assetlocktx.h>

#include <gsl/pointers.h>
#include <optional>
#include <unordered_set>

Expand Down Expand Up @@ -134,7 +135,8 @@ class CCreditPoolManager
std::optional<CCreditPool> 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<const CBlockIndex*> block_index, CCreditPool prev,
const Consensus::Params& consensusParams);
};

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

0 comments on commit bb82af5

Please sign in to comment.