2020-06-05 14:46:45 -07:00
|
|
|
// Copyright (c) 2020 The Zcash developers
|
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
|
|
|
|
|
|
|
#include <consensus/funding.h>
|
|
|
|
|
|
|
|
namespace Consensus
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* General information about each funding stream.
|
|
|
|
* Ordered by Consensus::FundingStreamIndex.
|
|
|
|
*/
|
|
|
|
const struct FSInfo FundingStreamInfo[Consensus::MAX_FUNDING_STREAMS] = {
|
|
|
|
{
|
2020-07-02 12:32:23 -07:00
|
|
|
.recipient = "Electric Coin Company",
|
|
|
|
.specification = "https://zips.z.cash/zip-0214",
|
|
|
|
.valueNumerator = 7,
|
|
|
|
.valueDenominator = 100,
|
2020-06-05 14:46:45 -07:00
|
|
|
},
|
|
|
|
{
|
2020-07-02 12:32:23 -07:00
|
|
|
.recipient = "Zcash Foundation",
|
|
|
|
.specification = "https://zips.z.cash/zip-0214",
|
|
|
|
.valueNumerator = 5,
|
|
|
|
.valueDenominator = 100,
|
2020-06-05 14:46:45 -07:00
|
|
|
},
|
|
|
|
{
|
2020-07-02 12:32:23 -07:00
|
|
|
.recipient = "Major Grants",
|
|
|
|
.specification = "https://zips.z.cash/zip-0214",
|
|
|
|
.valueNumerator = 8,
|
|
|
|
.valueDenominator = 100,
|
2020-06-05 14:46:45 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
CAmount FSInfo::Value(CAmount blockSubsidy) const
|
|
|
|
{
|
|
|
|
// Integer division is floor division for nonnegative integers in C++
|
|
|
|
return CAmount((blockSubsidy * valueNumerator) / valueDenominator);
|
|
|
|
}
|
|
|
|
|
2020-07-02 11:15:26 -07:00
|
|
|
std::set<FundingStreamElement> GetActiveFundingStreamElements(
|
2020-06-05 14:46:45 -07:00
|
|
|
int nHeight,
|
|
|
|
CAmount blockSubsidy,
|
|
|
|
const Consensus::Params& params)
|
|
|
|
{
|
2020-07-02 11:15:26 -07:00
|
|
|
std::set<std::pair<FundingStreamAddress, CAmount>> requiredElements;
|
2020-07-07 08:53:18 -07:00
|
|
|
for (uint32_t idx = Consensus::FIRST_FUNDING_STREAM; idx < Consensus::MAX_FUNDING_STREAMS; idx++) {
|
2020-07-06 12:12:55 -07:00
|
|
|
// The following indexed access is safe as Consensus::MAX_FUNDING_STREAMS is used
|
|
|
|
// in the definition of vFundingStreams.
|
2020-06-05 14:46:45 -07:00
|
|
|
auto fs = params.vFundingStreams[idx];
|
|
|
|
// Funding period is [startHeight, endHeight)
|
|
|
|
if (fs && nHeight >= fs.get().GetStartHeight() && nHeight < fs.get().GetEndHeight()) {
|
2020-07-02 11:15:26 -07:00
|
|
|
requiredElements.insert(std::make_pair(
|
2020-06-05 14:46:45 -07:00
|
|
|
fs.get().RecipientAddress(params, nHeight),
|
|
|
|
FundingStreamInfo[idx].Value(blockSubsidy)));
|
|
|
|
}
|
|
|
|
}
|
2020-07-02 11:15:26 -07:00
|
|
|
return requiredElements;
|
2020-06-05 14:46:45 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Consensus
|