consensus: Clearly gate active funding stream elements on Canopy
We only use the output of GetActiveFundingStreamElements and GetActiveFundingStreams within Canopy contexts, but this makes it explicit that funding streams are disabled before Canopy activation.
This commit is contained in:
parent
768534a8b9
commit
c595056883
|
@ -53,17 +53,22 @@ std::set<FundingStreamElement> GetActiveFundingStreamElements(
|
|||
const Consensus::Params& params)
|
||||
{
|
||||
std::set<std::pair<FundingStreamAddress, CAmount>> requiredElements;
|
||||
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 = params.vFundingStreams[idx];
|
||||
// Funding period is [startHeight, endHeight)
|
||||
if (fs && nHeight >= fs.get().GetStartHeight() && nHeight < fs.get().GetEndHeight()) {
|
||||
requiredElements.insert(std::make_pair(
|
||||
fs.get().RecipientAddress(params, nHeight),
|
||||
FundingStreamInfo[idx].Value(blockSubsidy)));
|
||||
|
||||
// Funding streams are disabled if height < CanopyActivationHeight
|
||||
if (params.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 = params.vFundingStreams[idx];
|
||||
// Funding period is [startHeight, endHeight)
|
||||
if (fs && nHeight >= fs.get().GetStartHeight() && nHeight < fs.get().GetEndHeight()) {
|
||||
requiredElements.insert(std::make_pair(
|
||||
fs.get().RecipientAddress(params, nHeight),
|
||||
FundingStreamInfo[idx].Value(blockSubsidy)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return requiredElements;
|
||||
};
|
||||
|
||||
|
@ -72,12 +77,17 @@ std::vector<FSInfo> GetActiveFundingStreams(
|
|||
const Consensus::Params& params)
|
||||
{
|
||||
std::vector<FSInfo> activeStreams;
|
||||
for (uint32_t idx = Consensus::FIRST_FUNDING_STREAM; idx < Consensus::MAX_FUNDING_STREAMS; idx++) {
|
||||
auto fs = params.vFundingStreams[idx];
|
||||
if (fs && nHeight >= fs.get().GetStartHeight() && nHeight < fs.get().GetEndHeight()) {
|
||||
activeStreams.push_back(FundingStreamInfo[idx]);
|
||||
|
||||
// Funding streams are disabled if height < CanopyActivationHeight
|
||||
if (params.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_CANOPY)) {
|
||||
for (uint32_t idx = Consensus::FIRST_FUNDING_STREAM; idx < Consensus::MAX_FUNDING_STREAMS; idx++) {
|
||||
auto fs = params.vFundingStreams[idx];
|
||||
if (fs && nHeight >= fs.get().GetStartHeight() && nHeight < fs.get().GetEndHeight()) {
|
||||
activeStreams.push_back(FundingStreamInfo[idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return activeStreams;
|
||||
};
|
||||
|
||||
|
|
|
@ -19,6 +19,12 @@ struct FSInfo {
|
|||
uint64_t valueNumerator;
|
||||
uint64_t valueDenominator;
|
||||
|
||||
/**
|
||||
* Returns the inherent value of this funding stream.
|
||||
*
|
||||
* For the active funding streams at a given height, use
|
||||
* GetActiveFundingStreams() or GetActiveFundingStreamElements().
|
||||
*/
|
||||
CAmount Value(CAmount blockSubsidy) const;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue