aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bitcoinrpc.cpp5
-rw-r--r--src/init.cpp15
-rw-r--r--src/main.h5
-rw-r--r--src/rpcblockchain.cpp5
-rw-r--r--src/test/util_tests.cpp58
-rw-r--r--src/txdb.cpp22
-rw-r--r--src/util.cpp9
7 files changed, 47 insertions, 72 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index 9c126fc3da..a9b73fd5a6 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -940,6 +940,11 @@ void ServiceConnection(AcceptedConnection *conn)
// Read HTTP message headers and body
ReadHTTPMessage(conn->stream(), mapHeaders, strRequest, nProto);
+ if (strURI != "/") {
+ conn->stream() << HTTPReply(HTTP_NOT_FOUND, "", false) << std::flush;
+ break;
+ }
+
// Check authorization
if (mapHeaders.count("authorization") == 0)
{
diff --git a/src/init.cpp b/src/init.cpp
index 3845cfad81..ea380f5a46 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -290,8 +290,7 @@ std::string HelpMessage()
" -? " + _("This help message") + "\n" +
" -conf=<file> " + _("Specify configuration file (default: bitcoin.conf)") + "\n" +
" -pid=<file> " + _("Specify pid file (default: bitcoind.pid)") + "\n" +
- " -gen " + _("Generate coins") + "\n" +
- " -gen=0 " + _("Don't generate coins") + "\n" +
+ " -gen " + _("Generate coins (default: 0)") + "\n" +
" -datadir=<dir> " + _("Specify data directory") + "\n" +
" -dbcache=<n> " + _("Set database cache size in megabytes (default: 25)") + "\n" +
" -timeout=<n> " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n" +
@@ -358,7 +357,7 @@ std::string HelpMessage()
" -txindex " + _("Maintain a full transaction index (default: 0)") + "\n" +
" -loadblock=<file> " + _("Imports blocks from external blk000??.dat file") + "\n" +
" -reindex " + _("Rebuild block chain index from current blk000??.dat files") + "\n" +
- " -par=N " + _("Set the number of script verification threads (up to 16, 0=auto, negative=leave N CPUs free, default: 0)") + "\n" +
+ " -par=<n> " + _("Set the number of script verification threads (up to 16, 0 = auto, <0 = leave that many cores free, default: 0)") + "\n" +
"\n" + _("Block creation options:") + "\n" +
" -blockminsize=<n> " + _("Set minimum block size in bytes (default: 0)") + "\n" +
@@ -466,9 +465,9 @@ bool AppInit2(boost::thread_group& threadGroup)
// Initialize Windows Sockets
WSADATA wsadata;
int ret = WSAStartup(MAKEWORD(2,2), &wsadata);
- if (ret != NO_ERROR)
+ if (ret != NO_ERROR || LOBYTE(wsadata.wVersion ) != 2 || HIBYTE(wsadata.wVersion) != 2)
{
- return InitError(strprintf("Error: TCP/IP socket library failed to start (WSAStartup returned error %d)", ret));
+ return InitError(strprintf("Error: Winsock library failed to start (WSAStartup returned error %d)", ret));
}
#endif
#ifndef WIN32
@@ -612,7 +611,7 @@ bool AppInit2(boost::thread_group& threadGroup)
if (!fLogTimestamps)
printf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()).c_str());
printf("Default data directory %s\n", GetDefaultDataDir().string().c_str());
- printf("Used data directory %s\n", strDataDir.c_str());
+ printf("Using data directory %s\n", strDataDir.c_str());
printf("Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD);
std::ostringstream strErrors;
@@ -988,6 +987,8 @@ bool AppInit2(boost::thread_group& threadGroup)
CBlockLocator locator;
if (walletdb.ReadBestBlock(locator))
pindexRescan = locator.GetBlockIndex();
+ else
+ pindexRescan = pindexGenesisBlock;
}
if (pindexBest && pindexBest != pindexRescan)
{
@@ -996,6 +997,8 @@ bool AppInit2(boost::thread_group& threadGroup)
nStart = GetTimeMillis();
pwalletMain->ScanForWalletTransactions(pindexRescan, true);
printf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart);
+ pwalletMain->SetBestChain(CBlockLocator(pindexBest));
+ nWalletDBUpdated++;
}
// ********************************************************* Step 9: import blocks
diff --git a/src/main.h b/src/main.h
index 24b2cb2aa6..e02edbc529 100644
--- a/src/main.h
+++ b/src/main.h
@@ -2096,11 +2096,14 @@ extern CTxMemPool mempool;
struct CCoinsStats
{
int nHeight;
+ uint256 hashBlock;
uint64 nTransactions;
uint64 nTransactionOutputs;
uint64 nSerializedSize;
+ uint256 hashSerialized;
+ int64 nTotalAmount;
- CCoinsStats() : nHeight(0), nTransactions(0), nTransactionOutputs(0), nSerializedSize(0) {}
+ CCoinsStats() : nHeight(0), hashBlock(0), nTransactions(0), nTransactionOutputs(0), nSerializedSize(0), hashSerialized(0), nTotalAmount(0) {}
};
/** Abstract view on the open txout dataset. */
diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
index 2200679050..11af1abf5d 100644
--- a/src/rpcblockchain.cpp
+++ b/src/rpcblockchain.cpp
@@ -172,10 +172,13 @@ Value gettxoutsetinfo(const Array& params, bool fHelp)
CCoinsStats stats;
if (pcoinsTip->GetStats(stats)) {
- ret.push_back(Pair("bestblock", pcoinsTip->GetBestBlock()->GetBlockHash().GetHex()));
+ ret.push_back(Pair("height", (boost::int64_t)stats.nHeight));
+ ret.push_back(Pair("bestblock", stats.hashBlock.GetHex()));
ret.push_back(Pair("transactions", (boost::int64_t)stats.nTransactions));
ret.push_back(Pair("txouts", (boost::int64_t)stats.nTransactionOutputs));
ret.push_back(Pair("bytes_serialized", (boost::int64_t)stats.nSerializedSize));
+ ret.push_back(Pair("hash_serialized", stats.hashSerialized.GetHex()));
+ ret.push_back(Pair("total_amount", ValueFromAmount(stats.nTotalAmount)));
}
return ret;
}
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
index 2d05794cc7..1b0ccad511 100644
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -323,62 +323,4 @@ BOOST_AUTO_TEST_CASE(util_seed_insecure_rand)
}
}
-static int nCounter = 0;
-
-static void Count()
-{
- ++nCounter;
- MilliSleep(10);
-}
-
-static void CountWithArg(int arg)
-{
- nCounter += arg;
- MilliSleep(10);
-}
-
-BOOST_AUTO_TEST_CASE(util_loop_forever1)
-{
- boost::thread_group threadGroup;
-
- threadGroup.create_thread(boost::bind(&LoopForever<void (*)()>, "count", &Count, 1));
- MilliSleep(1);
- threadGroup.interrupt_all();
- BOOST_CHECK_EQUAL(nCounter, 1);
- nCounter = 0;
-}
-
-BOOST_AUTO_TEST_CASE(util_loop_forever2)
-{
- boost::thread_group threadGroup;
-
- boost::function<void()> f = boost::bind(&CountWithArg, 11);
- threadGroup.create_thread(boost::bind(&LoopForever<boost::function<void()> >, "count11", f, 11));
- MilliSleep(1);
- threadGroup.interrupt_all();
- BOOST_CHECK_EQUAL(nCounter, 11);
- nCounter = 0;
-}
-
-BOOST_AUTO_TEST_CASE(util_threadtrace1)
-{
- boost::thread_group threadGroup;
-
- threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "count11", &Count));
- threadGroup.join_all();
- BOOST_CHECK_EQUAL(nCounter, 1);
- nCounter = 0;
-}
-
-BOOST_AUTO_TEST_CASE(util_threadtrace2)
-{
- boost::thread_group threadGroup;
-
- boost::function<void()> f = boost::bind(&CountWithArg, 11);
- threadGroup.create_thread(boost::bind(&TraceThread<boost::function<void()> >, "count11", f));
- threadGroup.join_all();
- BOOST_CHECK_EQUAL(nCounter, 11);
- nCounter = 0;
-}
-
BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/txdb.cpp b/src/txdb.cpp
index 5b0527c76c..3d34710d22 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -5,6 +5,7 @@
#include "txdb.h"
#include "main.h"
+#include "hash.h"
using namespace std;
@@ -114,6 +115,10 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) {
leveldb::Iterator *pcursor = db.NewIterator();
pcursor->SeekToFirst();
+ CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
+ stats.hashBlock = GetBestBlock()->GetBlockHash();
+ ss << stats.hashBlock;
+ int64 nTotalAmount = 0;
while (pcursor->Valid()) {
boost::this_thread::interruption_point();
try {
@@ -128,13 +133,22 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) {
ssValue >> coins;
uint256 txhash;
ssKey >> txhash;
-
+ ss << txhash;
+ ss << VARINT(coins.nVersion);
+ ss << (coins.fCoinBase ? 'c' : 'n');
+ ss << VARINT(coins.nHeight);
stats.nTransactions++;
- BOOST_FOREACH(const CTxOut &out, coins.vout) {
- if (!out.IsNull())
+ for (unsigned int i=0; i<coins.vout.size(); i++) {
+ const CTxOut &out = coins.vout[i];
+ if (!out.IsNull()) {
stats.nTransactionOutputs++;
+ ss << VARINT(i+1);
+ ss << out;
+ nTotalAmount += out.nValue;
+ }
}
stats.nSerializedSize += 32 + slValue.size();
+ ss << VARINT(0);
}
pcursor->Next();
} catch (std::exception &e) {
@@ -143,6 +157,8 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) {
}
delete pcursor;
stats.nHeight = GetBestBlock()->nHeight;
+ stats.hashSerialized = ss.GetHash();
+ stats.nTotalAmount = nTotalAmount;
return true;
}
diff --git a/src/util.cpp b/src/util.cpp
index 8b6d8b32c8..4c9b897f57 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -83,6 +83,7 @@ bool fNoListen = false;
bool fLogTimestamps = false;
CMedianFilter<int64> vTimeOffsets(200,0);
volatile bool fReopenDebugLog = false;
+bool fCachedPath[2] = {false, false};
// Init OpenSSL library multithreading support
static CCriticalSection** ppmutexOpenSSL;
@@ -1048,13 +1049,12 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific)
static fs::path pathCached[2];
static CCriticalSection csPathCached;
- static bool cachedPath[2] = {false, false};
fs::path &path = pathCached[fNetSpecific];
// This can be called during exceptions by printf, so we cache the
// value so we don't have to do memory allocations after that.
- if (cachedPath[fNetSpecific])
+ if (fCachedPath[fNetSpecific])
return path;
LOCK(csPathCached);
@@ -1073,7 +1073,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific)
fs::create_directory(path);
- cachedPath[fNetSpecific] = true;
+ fCachedPath[fNetSpecific] = true;
return path;
}
@@ -1091,6 +1091,9 @@ void ReadConfigFile(map<string, string>& mapSettingsRet,
if (!streamConfig.good())
return; // No bitcoin.conf file is OK
+ // clear path cache after loading config file
+ fCachedPath[0] = fCachedPath[1] = false;
+
set<string> setOptions;
setOptions.insert("*");