From feeb761ba07af74a7cd78b8c8f7c2a961fd9ea1c Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 12 Apr 2012 21:26:35 -0400 Subject: [PATCH 1/3] Testnet, Mark III --- src/irc.cpp | 4 ++-- src/main.cpp | 6 ++---- src/util.cpp | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/irc.cpp b/src/irc.cpp index 10491884..c0b3b747 100644 --- a/src/irc.cpp +++ b/src/irc.cpp @@ -291,8 +291,8 @@ void ThreadIRCSeed2(void* parg) } if (fTestNet) { - Send(hSocket, "JOIN #bitcoinTEST\r"); - Send(hSocket, "WHO #bitcoinTEST\r"); + Send(hSocket, "JOIN #bitcoinTEST3\r"); + Send(hSocket, "WHO #bitcoinTEST3\r"); } else { // randomly join #bitcoin00-#bitcoin99 int channel_number = GetRandInt(100); diff --git a/src/main.cpp b/src/main.cpp index 96718cf1..dd1a7b90 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1926,12 +1926,11 @@ bool LoadBlockIndex(bool fAllowNew) { if (fTestNet) { - hashGenesisBlock = uint256("0x00000007199508e34a9ff81e6ec0c477a4cccff2a4767a8eee39c11db367b008"); - bnProofOfWorkLimit = CBigNum(~uint256(0) >> 28); pchMessageStart[0] = 0xfa; pchMessageStart[1] = 0xbf; pchMessageStart[2] = 0xb5; pchMessageStart[3] = 0xda; + hashGenesisBlock = uint256("000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"); } // @@ -1977,8 +1976,7 @@ bool LoadBlockIndex(bool fAllowNew) if (fTestNet) { block.nTime = 1296688602; - block.nBits = 0x1d07fff8; - block.nNonce = 384568319; + block.nNonce = 414098458; } //// debug print diff --git a/src/util.cpp b/src/util.cpp index 3ab30baf..b07c9c1b 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -834,7 +834,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific) path = GetDefaultDataDir(); } if (fNetSpecific && GetBoolArg("-testnet", false)) - path /= "testnet"; + path /= "testnet3"; fs::create_directory(path); From 248bceb30c9ff3100f11a4755d8f0832f5189c14 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Fri, 13 Apr 2012 14:38:05 -0400 Subject: [PATCH 2/3] Fix issue#1082, testnet difficulty unsigned integer underflow --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index dd1a7b90..baffffd3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -865,12 +865,12 @@ unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast, const CBl // Only change once per interval if ((pindexLast->nHeight+1) % nInterval != 0) { - // Special rules for testnet after 15 Feb 2012: - if (fTestNet && pblock->nTime > 1329264000) + // Special difficulty rule for testnet: + if (fTestNet) { // If the new block's timestamp is more than 2* 10 minutes // then allow mining of a min-difficulty block. - if (pblock->nTime - pindexLast->nTime > nTargetSpacing*2) + if (pblock->nTime > pindexLast->nTime + nTargetSpacing*2) return nProofOfWorkLimit; else { From c87c8cd16344c7f7b45912bb0c68876f646eb04e Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Fri, 13 Apr 2012 14:53:31 -0400 Subject: [PATCH 3/3] Add a testnet checkpoint at block 546 --- src/checkpoints.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 6679bc93..6f7a92bb 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -35,27 +35,32 @@ namespace Checkpoints (168000, uint256("0x000000000000099e61ea72015e79632f216fe6cb33d7899acb35b75c8303b763")) ; + static MapCheckpoints mapCheckpointsTestnet = + boost::assign::map_list_of + ( 546, uint256("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")) + ; + bool CheckBlock(int nHeight, const uint256& hash) { - if (fTestNet) return true; // Testnet has no checkpoints + MapCheckpoints& checkpoints = (fTestNet ? mapCheckpointsTestnet : mapCheckpoints); - MapCheckpoints::const_iterator i = mapCheckpoints.find(nHeight); - if (i == mapCheckpoints.end()) return true; + MapCheckpoints::const_iterator i = checkpoints.find(nHeight); + if (i == checkpoints.end()) return true; return hash == i->second; } int GetTotalBlocksEstimate() { - if (fTestNet) return 0; + MapCheckpoints& checkpoints = (fTestNet ? mapCheckpointsTestnet : mapCheckpoints); - return mapCheckpoints.rbegin()->first; + return checkpoints.rbegin()->first; } CBlockIndex* GetLastCheckpoint(const std::map& mapBlockIndex) { - if (fTestNet) return NULL; + MapCheckpoints& checkpoints = (fTestNet ? mapCheckpointsTestnet : mapCheckpoints); - BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints) + BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, checkpoints) { const uint256& hash = i.second; std::map::const_iterator t = mapBlockIndex.find(hash);