Merge branch 'spork-reprocess'
This commit is contained in:
commit
7256d577c4
@ -3,7 +3,7 @@ AC_PREREQ([2.60])
|
||||
define(_CLIENT_VERSION_MAJOR, 0)
|
||||
define(_CLIENT_VERSION_MINOR, 11)
|
||||
define(_CLIENT_VERSION_REVISION, 1)
|
||||
define(_CLIENT_VERSION_BUILD, 21)
|
||||
define(_CLIENT_VERSION_BUILD, 22)
|
||||
define(_CLIENT_VERSION_IS_RELEASE, true)
|
||||
define(_COPYRIGHT_YEAR, 2015)
|
||||
AC_INIT([Darkcoin Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@darkcoin.io],[darkcoin])
|
||||
|
@ -12,7 +12,7 @@
|
||||
#define CLIENT_VERSION_MAJOR 0
|
||||
#define CLIENT_VERSION_MINOR 11
|
||||
#define CLIENT_VERSION_REVISION 1
|
||||
#define CLIENT_VERSION_BUILD 21
|
||||
#define CLIENT_VERSION_BUILD 22
|
||||
|
||||
|
||||
|
||||
|
19
src/main.cpp
19
src/main.cpp
@ -2473,6 +2473,19 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DisconnectBlocksAndReprocess(int blocks)
|
||||
{
|
||||
LOCK(cs_main);
|
||||
|
||||
CValidationState state;
|
||||
|
||||
LogPrintf("DisconnectBlocksAndReprocess: Got command to replay %d blocks", blocks);
|
||||
for(int i = 0; i <= blocks; i++)
|
||||
DisconnectTip(state);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
DisconnectBlockAndInputs
|
||||
|
||||
@ -3187,12 +3200,6 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
|
||||
|
||||
// Ask this guy to fill in what we're missing
|
||||
PushGetBlocks(pfrom, chainActive.Tip(), GetOrphanRoot(hash));
|
||||
|
||||
// Move backwards to tigger reprocessing both chains
|
||||
if(fLargeWorkForkFound || fLargeWorkInvalidChainFound || IsSporkActive(SPORK_4_RECONVERGE)){
|
||||
CValidationState state;
|
||||
DisconnectTip(state);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -613,6 +613,9 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
|
||||
/** Find a conflicting transcation in a block and disconnect all up to that point **/
|
||||
bool DisconnectBlockAndInputs(CValidationState &state, CTransaction txLock);
|
||||
|
||||
// reprocess a number of blocks to try and get on the correct chain again
|
||||
bool DisconnectBlocksAndReprocess(int blocks);
|
||||
|
||||
// Apply the effects of this block (with given index) on the UTXO set represented by coins
|
||||
bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& coins, bool fJustCheck = false);
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "base58.h"
|
||||
#include "protocol.h"
|
||||
#include "spork.h"
|
||||
#include "main.h"
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
using namespace std;
|
||||
@ -57,6 +58,8 @@ void ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
|
||||
mapSporksActive[spork.nSporkID] = spork;
|
||||
sporkManager.Relay(spork);
|
||||
|
||||
//does a task if needed
|
||||
ExecuteSpork(spork.nSporkID, spork.nValue);
|
||||
}
|
||||
if (strCommand == "getsporks")
|
||||
{
|
||||
@ -81,8 +84,8 @@ bool IsSporkActive(int nSporkID)
|
||||
if(nSporkID == SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT) r = SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT_DEFAULT;
|
||||
if(nSporkID == SPORK_2_INSTANTX) r = SPORK_2_INSTANTX_DEFAULT;
|
||||
if(nSporkID == SPORK_3_INSTANTX_BLOCK_FILTERING) r = SPORK_3_INSTANTX_BLOCK_FILTERING_DEFAULT;
|
||||
if(nSporkID == SPORK_4_RECONVERGE) r = SPORK_4_RECONVERGE_DEFAULT;
|
||||
if(nSporkID == SPORK_5_MAX_VALUE) r = SPORK_5_MAX_VALUE_DEFAULT;
|
||||
if(nSporkID == SPORK_6_REPLAY_BLOCKS) r = SPORK_6_REPLAY_BLOCKS_DEFAULT;
|
||||
|
||||
if(r == 0) LogPrintf("GetSpork::Unknown Spork %d\n", nSporkID);
|
||||
}
|
||||
@ -102,8 +105,8 @@ int GetSporkValue(int nSporkID)
|
||||
if(nSporkID == SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT) r = SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT_DEFAULT;
|
||||
if(nSporkID == SPORK_2_INSTANTX) r = SPORK_2_INSTANTX_DEFAULT;
|
||||
if(nSporkID == SPORK_3_INSTANTX_BLOCK_FILTERING) r = SPORK_3_INSTANTX_BLOCK_FILTERING_DEFAULT;
|
||||
if(nSporkID == SPORK_4_RECONVERGE) r = SPORK_4_RECONVERGE_DEFAULT;
|
||||
if(nSporkID == SPORK_5_MAX_VALUE) r = SPORK_5_MAX_VALUE_DEFAULT;
|
||||
if(nSporkID == SPORK_6_REPLAY_BLOCKS) r = SPORK_6_REPLAY_BLOCKS_DEFAULT;
|
||||
|
||||
if(r == 0) LogPrintf("GetSpork::Unknown Spork %d\n", nSporkID);
|
||||
}
|
||||
@ -111,6 +114,14 @@ int GetSporkValue(int nSporkID)
|
||||
return r;
|
||||
}
|
||||
|
||||
void ExecuteSpork(int nSporkID, int nValue)
|
||||
{
|
||||
//replay and process blocks (to sync to the longest chain after disabling sporks)
|
||||
if(nSporkID == SPORK_6_REPLAY_BLOCKS){
|
||||
DisconnectBlocksAndReprocess(nValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CSporkManager::CheckSignature(CSporkMessage& spork)
|
||||
{
|
||||
@ -206,8 +217,8 @@ int CSporkManager::GetSporkIDByName(std::string strName)
|
||||
if(strName == "SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT") return SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT;
|
||||
if(strName == "SPORK_2_INSTANTX") return SPORK_2_INSTANTX;
|
||||
if(strName == "SPORK_3_INSTANTX_BLOCK_FILTERING") return SPORK_3_INSTANTX_BLOCK_FILTERING;
|
||||
if(strName == "SPORK_4_RECONVERGE") return SPORK_4_RECONVERGE;
|
||||
if(strName == "SPORK_5_MAX_VALUE") return SPORK_5_MAX_VALUE;
|
||||
if(strName == "SPORK_6_REPLAY_BLOCKS") return SPORK_6_REPLAY_BLOCKS;
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -217,8 +228,8 @@ std::string CSporkManager::GetSporkNameByID(int id)
|
||||
if(id == SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT) return "SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT";
|
||||
if(id == SPORK_2_INSTANTX) return "SPORK_2_INSTANTX";
|
||||
if(id == SPORK_3_INSTANTX_BLOCK_FILTERING) return "SPORK_3_INSTANTX_BLOCK_FILTERING";
|
||||
if(id == SPORK_4_RECONVERGE) return "SPORK_4_RECONVERGE";
|
||||
if(id == SPORK_5_MAX_VALUE) return "SPORK_5_MAX_VALUE";
|
||||
if(id == SPORK_6_REPLAY_BLOCKS) return "SPORK_6_REPLAY_BLOCKS";
|
||||
|
||||
return "Unknown";
|
||||
}
|
@ -22,14 +22,16 @@ using namespace boost;
|
||||
#define SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT 10000
|
||||
#define SPORK_2_INSTANTX 10001
|
||||
#define SPORK_3_INSTANTX_BLOCK_FILTERING 10002
|
||||
#define SPORK_4_RECONVERGE 10003
|
||||
#define SPORK_4_NOTUSED 10003
|
||||
#define SPORK_5_MAX_VALUE 10004
|
||||
#define SPORK_6_REPLAY_BLOCKS 10005
|
||||
|
||||
#define SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT_DEFAULT 1424217600 //2015-2-18
|
||||
#define SPORK_2_INSTANTX_DEFAULT 978307200 //2001-1-1
|
||||
#define SPORK_3_INSTANTX_BLOCK_FILTERING_DEFAULT 1424217600 //2015-2-18
|
||||
#define SPORK_4_RECONVERGE_DEFAULT 4070908800 //2099-1-1
|
||||
#define SPORK_4_RECONVERGE_DEFAULT 1420070400 //2047-1-1
|
||||
#define SPORK_5_MAX_VALUE_DEFAULT 1000 //1000 DRK
|
||||
#define SPORK_6_REPLAY_BLOCKS_DEFAULT 0
|
||||
|
||||
class CSporkMessage;
|
||||
class CSporkManager;
|
||||
@ -52,6 +54,7 @@ extern CSporkManager sporkManager;
|
||||
void ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
|
||||
int GetSporkValue(int nSporkID);
|
||||
bool IsSporkActive(int nSporkID);
|
||||
void ExecuteSpork(int nSporkID, int nValue);
|
||||
|
||||
//
|
||||
// Spork Class
|
||||
|
Loading…
Reference in New Issue
Block a user