refactor: pull LimitBlocksToTrace into CChainParams (reduce regtest to 100)

This commit is contained in:
pasta 2024-10-29 12:53:47 -05:00
parent 93cfd5bc94
commit c8342e1b55
No known key found for this signature in database
GPG Key ID: E2F3D7916E722D38
4 changed files with 13 additions and 3 deletions

View File

@ -295,6 +295,8 @@ public:
vSporkAddresses = {"Xgtyuk76vhuFW2iT7UAiHgNdWXCf3J34wh"};
nMinSporkKeys = 1;
nCreditPoolPeriodBlocks = 576;
checkpointData = {
{
{1500, uint256S("0x000000aaf0300f59f49bc3e970bad15c11f961fe2347accffff19d96ec9778e3")},
@ -484,6 +486,8 @@ public:
vSporkAddresses = {"yjPtiKh2uwk3bDutTEA2q9mCtXyiZRWn55"};
nMinSporkKeys = 1;
nCreditPoolPeriodBlocks = 576;
checkpointData = {
{
{255, uint256S("0x0000080b600e06f4c07880673f027210f9314575f5f875fafe51971e268b886a")},
@ -664,6 +668,8 @@ public:
vSporkAddresses = {"yjPtiKh2uwk3bDutTEA2q9mCtXyiZRWn55"};
nMinSporkKeys = 1;
nCreditPoolPeriodBlocks = 576;
checkpointData = (CCheckpointData) {
{
{ 0, uint256S("0x000008ca1832a4baf228eb1553c03d3a2c8e02399550dd6ea8d65cec3ef23d2e")},
@ -866,6 +872,8 @@ public:
vSporkAddresses = {"yj949n1UH6fDhw6HtVE5VMj2iSTaSWBMcW"};
nMinSporkKeys = 1;
nCreditPoolPeriodBlocks = 100;
checkpointData = {
{
{0, uint256S("0x000008ca1832a4baf228eb1553c03d3a2c8e02399550dd6ea8d65cec3ef23d2e")},

View File

@ -152,6 +152,7 @@ public:
int FulfilledRequestExpireTime() const { return nFulfilledRequestExpireTime; }
const std::vector<std::string>& SporkAddresses() const { return vSporkAddresses; }
int MinSporkKeys() const { return nMinSporkKeys; }
int CreditPoolPeriodBlocks() const { return nCreditPoolPeriodBlocks; }
[[nodiscard]] std::optional<Consensus::LLMQParams> GetLLMQ(Consensus::LLMQType llmqType) const;
protected:
@ -188,6 +189,8 @@ protected:
int nMinSporkKeys;
uint16_t nDefaultPlatformP2PPort;
uint16_t nDefaultPlatformHTTPPort;
/// The number of blocks the credit pool tracks; 576 (one day) on mainnet, reduced on regtest
int nCreditPoolPeriodBlocks;
void AddLLMQ(Consensus::LLMQType llmqType);
};

View File

@ -153,7 +153,7 @@ CCreditPool CCreditPoolManager::ConstructCreditPool(const CBlockIndex* const blo
return opt_cbTx->creditPoolBalance;
}();
// We use here sliding window with LimitBlocksToTrace to determine
// We use here sliding window with Params().CreditPoolPeriodBlocks to determine
// current limits for asset unlock transactions.
// Indexes should not be duplicated since genesis block, but the Unlock Amount
// of withdrawal transaction is limited only by this window
@ -164,7 +164,7 @@ CCreditPool CCreditPoolManager::ConstructCreditPool(const CBlockIndex* const blo
}
const CBlockIndex* distant_block_index = block_index;
for (size_t i = 0; i < CCreditPoolManager::LimitBlocksToTrace; ++i) {
for (auto i = 0; i < Params().CreditPoolPeriodBlocks(); ++i) {
distant_block_index = distant_block_index->pprev;
if (distant_block_index == nullptr) break;
}

View File

@ -114,7 +114,6 @@ private:
static constexpr int DISK_SNAPSHOT_PERIOD = 576; // once per day
public:
static constexpr int LimitBlocksToTrace = 576;
static constexpr CAmount LimitAmountLow = 100 * COIN;
static constexpr CAmount LimitAmountHigh = 1000 * COIN;
static constexpr CAmount LimitAmountV22 = 2000 * COIN;