Merge branch '0.10' into v0.12.0.x_merge_btc010
This commit is contained in:
commit
e50d9bbc5d
@ -1,4 +1,4 @@
|
|||||||
Dash Core tree 0.11.x release notes can be found here:
|
Dash Core release notes can be found here:
|
||||||
- [v0.11.0](release-notes/release-notes-0.11.0.md) released Jan/15/2015
|
- [v0.11.0](release-notes/release-notes-0.11.0.md) released Jan/15/2015
|
||||||
- [v0.11.1](release-notes/release-notes-0.11.1.md) released Feb/10/2015.
|
- [v0.11.1](release-notes/release-notes-0.11.1.md) released Feb/10/2015.
|
||||||
- [v0.11.2](release-notes/release-notes-0.11.2.md) released Mar/25/2015.
|
- [v0.11.2](release-notes/release-notes-0.11.2.md) released Mar/25/2015.
|
||||||
|
34
qa/rpc-tests/reindex.py
Executable file
34
qa/rpc-tests/reindex.py
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env python2
|
||||||
|
# Copyright (c) 2014 The Bitcoin Core developers
|
||||||
|
# Distributed under the MIT software license, see the accompanying
|
||||||
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test -reindex with CheckBlockIndex
|
||||||
|
#
|
||||||
|
from test_framework import BitcoinTestFramework
|
||||||
|
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
|
||||||
|
from util import *
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
class ReindexTest(BitcoinTestFramework):
|
||||||
|
|
||||||
|
def setup_chain(self):
|
||||||
|
print("Initializing test directory "+self.options.tmpdir)
|
||||||
|
initialize_chain_clean(self.options.tmpdir, 1)
|
||||||
|
|
||||||
|
def setup_network(self):
|
||||||
|
self.nodes = []
|
||||||
|
self.is_network_split = False
|
||||||
|
self.nodes.append(start_node(0, self.options.tmpdir))
|
||||||
|
|
||||||
|
def run_test(self):
|
||||||
|
self.nodes[0].generate(3)
|
||||||
|
stop_node(self.nodes[0], 0)
|
||||||
|
wait_bitcoinds()
|
||||||
|
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug", "-reindex", "-checkblockindex=1"])
|
||||||
|
assert_equal(self.nodes[0].getblockcount(), 3)
|
||||||
|
print "Success"
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
ReindexTest().main()
|
@ -67,9 +67,8 @@ double CAddrInfo::GetChance(int64_t nNow) const
|
|||||||
if (nSinceLastTry < 60 * 10)
|
if (nSinceLastTry < 60 * 10)
|
||||||
fChance *= 0.01;
|
fChance *= 0.01;
|
||||||
|
|
||||||
// deprioritize 50% after each failed attempt
|
// deprioritize 66% after each failed attempt, but at most 1/28th to avoid the search taking forever or overly penalizing outages.
|
||||||
for (int n = 0; n < nAttempts; n++)
|
fChance *= pow(0.66, min(nAttempts, 8));
|
||||||
fChance /= 1.5;
|
|
||||||
|
|
||||||
return fChance;
|
return fChance;
|
||||||
}
|
}
|
||||||
|
21
src/main.cpp
21
src/main.cpp
@ -2732,10 +2732,6 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl
|
|||||||
pindexNew->nUndoPos = 0;
|
pindexNew->nUndoPos = 0;
|
||||||
pindexNew->nStatus |= BLOCK_HAVE_DATA;
|
pindexNew->nStatus |= BLOCK_HAVE_DATA;
|
||||||
pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS);
|
pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS);
|
||||||
{
|
|
||||||
LOCK(cs_nBlockSequenceId);
|
|
||||||
pindexNew->nSequenceId = nBlockSequenceId++;
|
|
||||||
}
|
|
||||||
setDirtyBlockIndex.insert(pindexNew);
|
setDirtyBlockIndex.insert(pindexNew);
|
||||||
|
|
||||||
if (pindexNew->pprev == NULL || pindexNew->pprev->nChainTx) {
|
if (pindexNew->pprev == NULL || pindexNew->pprev->nChainTx) {
|
||||||
@ -2748,6 +2744,10 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl
|
|||||||
CBlockIndex *pindex = queue.front();
|
CBlockIndex *pindex = queue.front();
|
||||||
queue.pop_front();
|
queue.pop_front();
|
||||||
pindex->nChainTx = (pindex->pprev ? pindex->pprev->nChainTx : 0) + pindex->nTx;
|
pindex->nChainTx = (pindex->pprev ? pindex->pprev->nChainTx : 0) + pindex->nTx;
|
||||||
|
{
|
||||||
|
LOCK(cs_nBlockSequenceId);
|
||||||
|
pindex->nSequenceId = nBlockSequenceId++;
|
||||||
|
}
|
||||||
if (chainActive.Tip() == NULL || !setBlockIndexCandidates.value_comp()(pindex, chainActive.Tip())) {
|
if (chainActive.Tip() == NULL || !setBlockIndexCandidates.value_comp()(pindex, chainActive.Tip())) {
|
||||||
setBlockIndexCandidates.insert(pindex);
|
setBlockIndexCandidates.insert(pindex);
|
||||||
}
|
}
|
||||||
@ -3720,6 +3720,14 @@ void static CheckBlockIndex()
|
|||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
|
// During a reindex, we read the genesis block and call CheckBlockIndex before ActivateBestChain,
|
||||||
|
// so we have the genesis block in mapBlockIndex but no active chain. (A few of the tests when
|
||||||
|
// iterating the block tree require that chainActive has been initialized.)
|
||||||
|
if (chainActive.Height() < 0) {
|
||||||
|
assert(mapBlockIndex.size() <= 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Build forward-pointing map of the entire block tree.
|
// Build forward-pointing map of the entire block tree.
|
||||||
std::multimap<CBlockIndex*,CBlockIndex*> forward;
|
std::multimap<CBlockIndex*,CBlockIndex*> forward;
|
||||||
for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); it++) {
|
for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); it++) {
|
||||||
@ -3757,6 +3765,11 @@ void static CheckBlockIndex()
|
|||||||
assert(pindex->GetBlockHash() == Params().HashGenesisBlock()); // Genesis block's hash must match.
|
assert(pindex->GetBlockHash() == Params().HashGenesisBlock()); // Genesis block's hash must match.
|
||||||
assert(pindex == chainActive.Genesis()); // The current active chain's genesis block must be this block.
|
assert(pindex == chainActive.Genesis()); // The current active chain's genesis block must be this block.
|
||||||
}
|
}
|
||||||
|
// HAVE_DATA is equivalent to VALID_TRANSACTIONS and equivalent to nTx > 0 (we stored the number of transactions in the block)
|
||||||
|
assert(!(pindex->nStatus & BLOCK_HAVE_DATA) == (pindex->nTx == 0));
|
||||||
|
assert(((pindex->nStatus & BLOCK_VALID_MASK) >= BLOCK_VALID_TRANSACTIONS) == (pindex->nTx > 0));
|
||||||
|
if (pindex->nChainTx == 0) assert(pindex->nSequenceId == 0); // nSequenceId can't be set for blocks that aren't linked
|
||||||
|
// All parents having data is equivalent to all parents being VALID_TRANSACTIONS, which is equivalent to nChainTx being set.
|
||||||
assert((pindexFirstMissing != NULL) == (pindex->nChainTx == 0)); // nChainTx == 0 is used to signal that all parent block's transaction data is available.
|
assert((pindexFirstMissing != NULL) == (pindex->nChainTx == 0)); // nChainTx == 0 is used to signal that all parent block's transaction data is available.
|
||||||
assert(pindex->nHeight == nHeight); // nHeight must be consistent.
|
assert(pindex->nHeight == nHeight); // nHeight must be consistent.
|
||||||
assert(pindex->pprev == NULL || pindex->nChainWork >= pindex->pprev->nChainWork); // For every block except the genesis block, the chainwork must be larger than the parent's.
|
assert(pindex->pprev == NULL || pindex->nChainWork >= pindex->pprev->nChainWork); // For every block except the genesis block, the chainwork must be larger than the parent's.
|
||||||
|
@ -502,8 +502,16 @@ void static BitcoinMiner(CWallet *pwallet)
|
|||||||
if (Params().MiningRequiresPeers()) {
|
if (Params().MiningRequiresPeers()) {
|
||||||
// Busy-wait for the network to come online so we don't waste time mining
|
// Busy-wait for the network to come online so we don't waste time mining
|
||||||
// on an obsolete chain. In regtest mode we expect to fly solo.
|
// on an obsolete chain. In regtest mode we expect to fly solo.
|
||||||
while (vNodes.empty())
|
do {
|
||||||
|
bool fvNodesEmpty;
|
||||||
|
{
|
||||||
|
LOCK(cs_vNodes);
|
||||||
|
fvNodesEmpty = vNodes.empty();
|
||||||
|
}
|
||||||
|
if (!fvNodesEmpty && !IsInitialBlockDownload())
|
||||||
|
break;
|
||||||
MilliSleep(1000);
|
MilliSleep(1000);
|
||||||
|
} while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -616,6 +624,11 @@ void static BitcoinMiner(CWallet *pwallet)
|
|||||||
LogPrintf("DashMiner terminated\n");
|
LogPrintf("DashMiner terminated\n");
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
catch (const std::runtime_error &e)
|
||||||
|
{
|
||||||
|
LogPrintf("BitcoinMiner runtime error: %s\n", e.what());
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads)
|
void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads)
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "config/dash-config.h"
|
#include "config/dash-config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
#include "uritests.h"
|
#include "uritests.h"
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
@ -28,6 +29,7 @@ Q_IMPORT_PLUGIN(qkrcodecs)
|
|||||||
// This is all you need to run all the tests
|
// This is all you need to run all the tests
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
SetupEnvironment();
|
||||||
bool fInvalid = false;
|
bool fInvalid = false;
|
||||||
|
|
||||||
// Don't remove this, it's needed to access
|
// Don't remove this, it's needed to access
|
||||||
|
@ -288,7 +288,7 @@ Value listunspent(const Array& params, bool fHelp)
|
|||||||
if (pk.IsPayToScriptHash()) {
|
if (pk.IsPayToScriptHash()) {
|
||||||
CTxDestination address;
|
CTxDestination address;
|
||||||
if (ExtractDestination(pk, address)) {
|
if (ExtractDestination(pk, address)) {
|
||||||
const CScriptID& hash = boost::get<const CScriptID&>(address);
|
const CScriptID& hash = boost::get<CScriptID>(address);
|
||||||
CScript redeemScript;
|
CScript redeemScript;
|
||||||
if (pwalletMain->GetCScript(hash, redeemScript))
|
if (pwalletMain->GetCScript(hash, redeemScript))
|
||||||
entry.push_back(Pair("redeemScript", HexStr(redeemScript.begin(), redeemScript.end())));
|
entry.push_back(Pair("redeemScript", HexStr(redeemScript.begin(), redeemScript.end())));
|
||||||
|
@ -30,6 +30,7 @@ struct TestingSetup {
|
|||||||
boost::thread_group threadGroup;
|
boost::thread_group threadGroup;
|
||||||
|
|
||||||
TestingSetup() {
|
TestingSetup() {
|
||||||
|
SetupEnvironment();
|
||||||
fPrintToDebugLog = false; // don't want to write to debug.log file
|
fPrintToDebugLog = false; // don't want to write to debug.log file
|
||||||
fCheckBlockIndex = true;
|
fCheckBlockIndex = true;
|
||||||
SelectParams(CBaseChainParams::UNITTEST);
|
SelectParams(CBaseChainParams::UNITTEST);
|
||||||
|
@ -757,12 +757,15 @@ void SetupEnvironment()
|
|||||||
try {
|
try {
|
||||||
std::locale(""); // Raises a runtime error if current locale is invalid
|
std::locale(""); // Raises a runtime error if current locale is invalid
|
||||||
} catch (const std::runtime_error&) {
|
} catch (const std::runtime_error&) {
|
||||||
std::locale::global(std::locale("C"));
|
setenv("LC_ALL", "C", 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// The path locale is lazy initialized and to avoid deinitialization errors
|
// The path locale is lazy initialized and to avoid deinitialization errors
|
||||||
// in multithreading environments, it is set explicitly by the main thread.
|
// in multithreading environments, it is set explicitly by the main thread.
|
||||||
boost::filesystem::path::imbue(std::locale());
|
// A dummy locale is used to extract the internal default locale, used by
|
||||||
|
// boost::filesystem::path, which is then used to explicitly imbue the path.
|
||||||
|
std::locale loc = boost::filesystem::path::imbue(std::locale::classic());
|
||||||
|
boost::filesystem::path::imbue(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetThreadPriority(int nPriority)
|
void SetThreadPriority(int nPriority)
|
||||||
|
Loading…
Reference in New Issue
Block a user