@@ -194,7 +194,7 @@ namespace Consensus {
194
194
195
195
const auto expectedRecipients = params.FundingPeriodIndex (startHeight, endHeight - 1 ) + 1 ;
196
196
if (expectedRecipients > recipients.size ()) {
197
- return FundingStreamError::INSUFFICIENT_ADDRESSES ;
197
+ return FundingStreamError::INSUFFICIENT_RECIPIENTS ;
198
198
}
199
199
200
200
// Lockbox output periods must not start before NU6
@@ -221,8 +221,8 @@ namespace Consensus {
221
221
throw std::runtime_error (" Canopy network upgrade not active at funding stream start height." );
222
222
case FundingStreamError::ILLEGAL_RANGE:
223
223
throw std::runtime_error (" Illegal start/end height combination for funding stream." );
224
- case FundingStreamError::INSUFFICIENT_ADDRESSES :
225
- throw std::runtime_error (" Insufficient payment addresses to fully exhaust funding stream." );
224
+ case FundingStreamError::INSUFFICIENT_RECIPIENTS :
225
+ throw std::runtime_error (" Insufficient recipient identifiers to fully exhaust funding stream." );
226
226
case FundingStreamError::NU6_NOT_ACTIVE:
227
227
throw std::runtime_error (" NU6 network upgrade not active at lockbox period start height." );
228
228
default :
@@ -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