Browse Source

checkpoints + soft checkpoint update

miguelfreitas
Miguel Freitas 11 years ago
parent
commit
85fa3d4b9a
  1. 5
      src/checkpoints.cpp
  2. 24
      src/softcheckpoint.cpp

5
src/checkpoints.cpp

@ -44,11 +44,12 @@ namespace Checkpoints
( 18050, uint256("0xef0d4c9e318a952dd45fcb1c867996df309a0fb586811479c08cf18a176a8864")) ( 18050, uint256("0xef0d4c9e318a952dd45fcb1c867996df309a0fb586811479c08cf18a176a8864"))
( 18973, uint256("0x5f3f60fec53ac03434907ca980b5349875822794a4a0b50b78bcf0411d0c95fe")) ( 18973, uint256("0x5f3f60fec53ac03434907ca980b5349875822794a4a0b50b78bcf0411d0c95fe"))
( 20200, uint256("0x31f84d32e843baa1fd73b0013466c206ad8a783aaaeab61219bcea2475e1d05d")) ( 20200, uint256("0x31f84d32e843baa1fd73b0013466c206ad8a783aaaeab61219bcea2475e1d05d"))
( 20988, uint256("0x8e022eb85240176a82bac5e9ba5ad7bd05cb43f2073e08c462b1ba1ac012ba42"))
; ;
static const CCheckpointData data = { static const CCheckpointData data = {
&mapCheckpoints, &mapCheckpoints,
1389861305, // * UNIX timestamp of last checkpoint block 1390337493, // * UNIX timestamp of last checkpoint block
24805, // * total number of transactions between genesis and last checkpoint 36312, // * total number of transactions between genesis and last checkpoint
// (the tx=... number in the SetBestChain debug.log lines) // (the tx=... number in the SetBestChain debug.log lines)
144.0 // * estimated number of transactions per day after checkpoint 144.0 // * estimated number of transactions per day after checkpoint
}; };

24
src/softcheckpoint.cpp

@ -37,6 +37,10 @@ namespace SoftCheckpoints
static std::set<std::string> uniqueUsersList = static std::set<std::string> uniqueUsersList =
boost::assign::list_of boost::assign::list_of
("mf1")("mf1a")("mf2")("mf2a")("mf3"); ("mf1")("mf1a")("mf2")("mf2a")("mf3");
static std::set<std::string> upcomingUsersList =
boost::assign::list_of
("_gltest2")("wn41")("quietpatron");
void SetSoftCPBestChain() { void SetSoftCPBestChain() {
@ -84,13 +88,13 @@ namespace SoftCheckpoints
if( (nBestHeight % SOFT_CHECKPOINT_PERIOD) == 0 && if( (nBestHeight % SOFT_CHECKPOINT_PERIOD) == 0 &&
nBestHeight > Checkpoints::GetHighestCheckpoint() && nBestHeight > Checkpoints::GetHighestCheckpoint() &&
nBestHeight > lastSoftCP.first + SOFT_CHECKPOINT_PERIOD && nBestHeight >= lastSoftCP.first + SOFT_CHECKPOINT_PERIOD &&
!fImporting && !fReindex) { !fImporting && !fReindex) {
LOCK(pwalletMain->cs_wallet); LOCK(pwalletMain->cs_wallet);
BOOST_FOREACH(const PAIRTYPE(CKeyID, CKeyMetadata)& item, pwalletMain->mapKeyMetadata) BOOST_FOREACH(const PAIRTYPE(CKeyID, CKeyMetadata)& item, pwalletMain->mapKeyMetadata)
{ {
const std::string &username = item.second.username; const std::string &username = item.second.username;
if(uniqueUsersList.count(username)) { if(uniqueUsersList.count(username) || upcomingUsersList.count(username)) {
int height = nBestHeight - SOFT_CHECKPOINT_PERIOD; int height = nBestHeight - SOFT_CHECKPOINT_PERIOD;
dbgprintf("SoftCheckpoints::NewBlockAccepted: user '%s' will vote for %d\n", dbgprintf("SoftCheckpoints::NewBlockAccepted: user '%s' will vote for %d\n",
username.c_str(), height); username.c_str(), height);
@ -123,6 +127,14 @@ namespace SoftCheckpoints
} }
} }
} }
if( uncheckedCandidates.size() && nBestHeight > Checkpoints::GetHighestCheckpoint() ) {
// pending unchecked
dbgprintf("SoftCheckpoints::NewBlockAccepted process %zd pending unchecked (not implemented)\n",
uncheckedCandidates.size());
uncheckedCandidates.clear();
}
} }
bool CastVerifiedVote(Checkpoint &cp, const std::string &username, const std::string &sign) { bool CastVerifiedVote(Checkpoint &cp, const std::string &username, const std::string &sign) {
@ -177,7 +189,7 @@ namespace SoftCheckpoints
return false; return false;
} }
if( !uniqueUsersList.count(username) ) { if( !uniqueUsersList.count(username) && !upcomingUsersList.count(username) ) {
dbgprintf("SoftCheckpoints::CastVoteSoftCheckpoint: username '%s' not accepted\n", username.c_str()); dbgprintf("SoftCheckpoints::CastVoteSoftCheckpoint: username '%s' not accepted\n", username.c_str());
return false; return false;
} }
@ -196,7 +208,8 @@ namespace SoftCheckpoints
return false; return false;
} }
dbgprintf("SoftCheckpoints::CastVoteSoftCheckpoint: signature by '%s' verified, casting vote\n", username.c_str()); dbgprintf("SoftCheckpoints::CastVoteSoftCheckpoint: signature by '%s' verified for %d, casting vote\n",
username.c_str(), height);
return CastVerifiedVote( cp, username, sign ); return CastVerifiedVote( cp, username, sign );
} }
@ -213,7 +226,8 @@ namespace SoftCheckpoints
void RelayCP(const CSoftCheckpoint& cp, CNode* pfrom) { void RelayCP(const CSoftCheckpoint& cp, CNode* pfrom) {
LOCK(cs_vNodes); LOCK(cs_vNodes);
dbgprintf("SoftCheckpoints::RelayCP: relaying softCP height %d\n", cp.nHeight); dbgprintf("SoftCheckpoints::RelayCP: relaying softCP height %d from %s\n",
cp.nHeight, !pfrom ? "localhost" : pfrom->addr.ToString().c_str());
BOOST_FOREACH(CNode* pnode, vNodes) { BOOST_FOREACH(CNode* pnode, vNodes) {
if(pnode == pfrom) if(pnode == pfrom)
continue; continue;

Loading…
Cancel
Save