Skip to content

Commit

Permalink
Simplify GetActiveFundingStreamElements.
Browse files Browse the repository at this point in the history
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
  • Loading branch information
daira committed Oct 4, 2024
1 parent e368a29 commit 96bf945
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/consensus/params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,11 @@ namespace Consensus {
// Funding streams are disabled if Canopy is not active.
if (NetworkUpgradeActive(nHeight, Consensus::UPGRADE_CANOPY)) {
for (uint32_t idx = Consensus::FIRST_FUNDING_STREAM; idx < Consensus::MAX_FUNDING_STREAMS; idx++) {
// The following indexed access is safe as Consensus::MAX_FUNDING_STREAMS is used
// in the definition of vFundingStreams.
auto fs = vFundingStreams[idx];

// Funding period is [startHeight, endHeight).
if (fs && nHeight >= fs.value().GetStartHeight() && nHeight < fs.value().GetEndHeight()) {
activeStreams.push_back(std::make_pair(FundingStreamInfo[idx], fs.value()));
}
Expand All @@ -372,16 +376,10 @@ namespace Consensus {

// Funding streams are disabled if Canopy is not active.
if (NetworkUpgradeActive(nHeight, Consensus::UPGRADE_CANOPY)) {
for (uint32_t idx = Consensus::FIRST_FUNDING_STREAM; idx < Consensus::MAX_FUNDING_STREAMS; idx++) {
// The following indexed access is safe as Consensus::MAX_FUNDING_STREAMS is used
// in the definition of vFundingStreams.
auto fs = vFundingStreams[idx];
// Funding period is [startHeight, endHeight)
if (fs && nHeight >= fs.value().GetStartHeight() && nHeight < fs.value().GetEndHeight()) {
requiredElements.insert(std::make_pair(
fs.value().Recipient(*this, nHeight),
FundingStreamInfo[idx].Value(blockSubsidy)));
}
for (const auto& [fsinfo, fs] : GetActiveFundingStreams(nHeight)) {
requiredElements.insert(std::make_pair(
fs.Recipient(*this, nHeight),
fsinfo.Value(blockSubsidy)));
}
}

Expand Down

0 comments on commit 96bf945

Please sign in to comment.