mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Simplify spork defaults by using a map (#2037)
This commit is contained in:
parent
6dd8304a5c
commit
f8e5c5d56e
@ -16,6 +16,17 @@
|
||||
CSporkManager sporkManager;
|
||||
|
||||
std::map<uint256, CSporkMessage> mapSporks;
|
||||
std::map<int, int64_t> mapSporkDefaults = {
|
||||
{SPORK_2_INSTANTSEND_ENABLED, 0}, // ON
|
||||
{SPORK_3_INSTANTSEND_BLOCK_FILTERING, 0}, // ON
|
||||
{SPORK_5_INSTANTSEND_MAX_VALUE, 1000}, // 1000 Dash
|
||||
{SPORK_6_NEW_SIGS, 4070908800ULL}, // OFF
|
||||
{SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT, 4070908800ULL}, // OFF
|
||||
{SPORK_9_SUPERBLOCKS_ENABLED, 4070908800ULL}, // OFF
|
||||
{SPORK_10_MASTERNODE_PAY_UPDATED_NODES, 4070908800ULL}, // OFF
|
||||
{SPORK_12_RECONSIDER_BLOCKS, 0}, // 0 BLOCKS
|
||||
{SPORK_14_REQUIRE_SENTINEL_FLAG, 4070908800ULL}, // OFF
|
||||
};
|
||||
|
||||
void CSporkManager::ProcessSpork(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman)
|
||||
{
|
||||
@ -124,22 +135,11 @@ bool CSporkManager::IsSporkActive(int nSporkID)
|
||||
|
||||
if(mapSporksActive.count(nSporkID)){
|
||||
r = mapSporksActive[nSporkID].nValue;
|
||||
} else if (mapSporkDefaults.count(nSporkID)) {
|
||||
r = mapSporkDefaults[nSporkID];
|
||||
} else {
|
||||
switch (nSporkID) {
|
||||
case SPORK_2_INSTANTSEND_ENABLED: r = SPORK_2_INSTANTSEND_ENABLED_DEFAULT; break;
|
||||
case SPORK_3_INSTANTSEND_BLOCK_FILTERING: r = SPORK_3_INSTANTSEND_BLOCK_FILTERING_DEFAULT; break;
|
||||
case SPORK_5_INSTANTSEND_MAX_VALUE: r = SPORK_5_INSTANTSEND_MAX_VALUE_DEFAULT; break;
|
||||
case SPORK_6_NEW_SIGS: r = SPORK_6_NEW_SIGS_DEFAULT; break;
|
||||
case SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT: r = SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT_DEFAULT; break;
|
||||
case SPORK_9_SUPERBLOCKS_ENABLED: r = SPORK_9_SUPERBLOCKS_ENABLED_DEFAULT; break;
|
||||
case SPORK_10_MASTERNODE_PAY_UPDATED_NODES: r = SPORK_10_MASTERNODE_PAY_UPDATED_NODES_DEFAULT; break;
|
||||
case SPORK_12_RECONSIDER_BLOCKS: r = SPORK_12_RECONSIDER_BLOCKS_DEFAULT; break;
|
||||
case SPORK_14_REQUIRE_SENTINEL_FLAG: r = SPORK_14_REQUIRE_SENTINEL_FLAG_DEFAULT; break;
|
||||
default:
|
||||
LogPrint("spork", "CSporkManager::IsSporkActive -- Unknown Spork ID %d\n", nSporkID);
|
||||
r = 4070908800ULL; // 2099-1-1 i.e. off by default
|
||||
break;
|
||||
}
|
||||
LogPrint("spork", "CSporkManager::IsSporkActive -- Unknown Spork ID %d\n", nSporkID);
|
||||
r = 4070908800ULL; // 2099-1-1 i.e. off by default
|
||||
}
|
||||
|
||||
return r < GetAdjustedTime();
|
||||
@ -151,21 +151,12 @@ int64_t CSporkManager::GetSporkValue(int nSporkID)
|
||||
if (mapSporksActive.count(nSporkID))
|
||||
return mapSporksActive[nSporkID].nValue;
|
||||
|
||||
switch (nSporkID) {
|
||||
case SPORK_2_INSTANTSEND_ENABLED: return SPORK_2_INSTANTSEND_ENABLED_DEFAULT;
|
||||
case SPORK_3_INSTANTSEND_BLOCK_FILTERING: return SPORK_3_INSTANTSEND_BLOCK_FILTERING_DEFAULT;
|
||||
case SPORK_5_INSTANTSEND_MAX_VALUE: return SPORK_5_INSTANTSEND_MAX_VALUE_DEFAULT;
|
||||
case SPORK_6_NEW_SIGS: return SPORK_6_NEW_SIGS_DEFAULT;
|
||||
case SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT: return SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT_DEFAULT;
|
||||
case SPORK_9_SUPERBLOCKS_ENABLED: return SPORK_9_SUPERBLOCKS_ENABLED_DEFAULT;
|
||||
case SPORK_10_MASTERNODE_PAY_UPDATED_NODES: return SPORK_10_MASTERNODE_PAY_UPDATED_NODES_DEFAULT;
|
||||
case SPORK_12_RECONSIDER_BLOCKS: return SPORK_12_RECONSIDER_BLOCKS_DEFAULT;
|
||||
case SPORK_14_REQUIRE_SENTINEL_FLAG: return SPORK_14_REQUIRE_SENTINEL_FLAG_DEFAULT;
|
||||
default:
|
||||
LogPrint("spork", "CSporkManager::GetSporkValue -- Unknown Spork ID %d\n", nSporkID);
|
||||
return -1;
|
||||
if (mapSporkDefaults.count(nSporkID)) {
|
||||
return mapSporkDefaults[nSporkID];
|
||||
}
|
||||
|
||||
LogPrint("spork", "CSporkManager::GetSporkValue -- Unknown Spork ID %d\n", nSporkID);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CSporkManager::GetSporkIDByName(const std::string& strName)
|
||||
|
11
src/spork.h
11
src/spork.h
@ -30,16 +30,7 @@ static const int SPORK_10_MASTERNODE_PAY_UPDATED_NODES = 10009;
|
||||
static const int SPORK_12_RECONSIDER_BLOCKS = 10011;
|
||||
static const int SPORK_14_REQUIRE_SENTINEL_FLAG = 10013;
|
||||
|
||||
static const int64_t SPORK_2_INSTANTSEND_ENABLED_DEFAULT = 0; // ON
|
||||
static const int64_t SPORK_3_INSTANTSEND_BLOCK_FILTERING_DEFAULT = 0; // ON
|
||||
static const int64_t SPORK_5_INSTANTSEND_MAX_VALUE_DEFAULT = 1000; // 1000 DASH
|
||||
static const int64_t SPORK_6_NEW_SIGS_DEFAULT = 4070908800ULL;// OFF
|
||||
static const int64_t SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT_DEFAULT = 4070908800ULL;// OFF
|
||||
static const int64_t SPORK_9_SUPERBLOCKS_ENABLED_DEFAULT = 4070908800ULL;// OFF
|
||||
static const int64_t SPORK_10_MASTERNODE_PAY_UPDATED_NODES_DEFAULT = 4070908800ULL;// OFF
|
||||
static const int64_t SPORK_12_RECONSIDER_BLOCKS_DEFAULT = 0; // 0 BLOCKS
|
||||
static const int64_t SPORK_14_REQUIRE_SENTINEL_FLAG_DEFAULT = 4070908800ULL;// OFF
|
||||
|
||||
extern std::map<int, int64_t> mapSporkDefaults;
|
||||
extern std::map<uint256, CSporkMessage> mapSporks;
|
||||
extern CSporkManager sporkManager;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user