@@ -349,7 +349,11 @@ namespace Consensus {
349
349
// Funding streams are disabled if Canopy is not active.
350
350
if (NetworkUpgradeActive (nHeight, Consensus::UPGRADE_CANOPY)) {
351
351
for (uint32_t idx = Consensus::FIRST_FUNDING_STREAM; idx < Consensus::MAX_FUNDING_STREAMS; idx++) {
352
+ // The following indexed access is safe as Consensus::MAX_FUNDING_STREAMS is used
353
+ // in the definition of vFundingStreams.
352
354
auto fs = vFundingStreams[idx];
355
+
356
+ // Funding period is [startHeight, endHeight).
353
357
if (fs && nHeight >= fs.value ().GetStartHeight () && nHeight < fs.value ().GetEndHeight ()) {
354
358
activeStreams.push_back (std::make_pair (FundingStreamInfo[idx], fs.value ()));
355
359
}
@@ -372,16 +376,10 @@ namespace Consensus {
372
376
373
377
// Funding streams are disabled if Canopy is not active.
374
378
if (NetworkUpgradeActive (nHeight, Consensus::UPGRADE_CANOPY)) {
375
- for (uint32_t idx = Consensus::FIRST_FUNDING_STREAM; idx < Consensus::MAX_FUNDING_STREAMS; idx++) {
376
- // The following indexed access is safe as Consensus::MAX_FUNDING_STREAMS is used
377
- // in the definition of vFundingStreams.
378
- auto fs = vFundingStreams[idx];
379
- // Funding period is [startHeight, endHeight)
380
- if (fs && nHeight >= fs.value ().GetStartHeight () && nHeight < fs.value ().GetEndHeight ()) {
381
- requiredElements.insert (std::make_pair (
382
- fs.value ().Recipient (*this , nHeight),
383
- FundingStreamInfo[idx].Value (blockSubsidy)));
384
- }
379
+ for (const auto & [fsinfo, fs] : GetActiveFundingStreams (nHeight)) {
380
+ requiredElements.insert (std::make_pair (
381
+ fs.Recipient (*this , nHeight),
382
+ fsinfo.Value (blockSubsidy)));
385
383
}
386
384
}
387
385
0 commit comments