From 3b7cd5d89a226426df9c723d1f9ddfe08b7d1def Mon Sep 17 00:00:00 2001 From: s_nakamoto Date: Sun, 25 Jul 2010 16:45:21 +0000 Subject: Gavin Andresen's JSON-RPC HTTP authentication, faster initial block download -- version 0.3.3 git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@109 1a98c847-1fd6-4fd8-948a-caf3550aa51b --- util.cpp | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'util.cpp') diff --git a/util.cpp b/util.cpp index 4ddc5250e..5d3728a13 100644 --- a/util.cpp +++ b/util.cpp @@ -416,7 +416,7 @@ void ParseParameters(int argc, char* argv[]) { mapArgs.clear(); mapMultiArgs.clear(); - for (int i = 0; i < argc; i++) + for (int i = 1; i < argc; i++) { char psz[10000]; strlcpy(psz, argv[i], sizeof(psz)); @@ -431,6 +431,8 @@ void ParseParameters(int argc, char* argv[]) if (psz[0] == '/') psz[0] = '-'; #endif + if (psz[0] != '-') + break; mapArgs[psz] = pszValue; mapMultiArgs[psz].push_back(pszValue); } @@ -619,6 +621,38 @@ string GetDataDir() return pszDir; } +string GetConfigFile() +{ + namespace fs = boost::filesystem; + fs::path pathConfig(mapArgs.count("-conf") ? mapArgs["-conf"] : string("bitcoin.conf")); + if (!pathConfig.is_complete()) + pathConfig = fs::path(GetDataDir()) / pathConfig; + return pathConfig.string(); +} + +void ReadConfigFile(map& mapSettingsRet, + map >& mapMultiSettingsRet) +{ + namespace fs = boost::filesystem; + namespace pod = boost::program_options::detail; + + fs::ifstream streamConfig(GetConfigFile()); + if (!streamConfig.good()) + return; + + set setOptions; + setOptions.insert("*"); + + for (pod::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it) + { + // Don't overwrite existing settings so command line settings override bitcoin.conf + string strKey = string("-") + it->string_key; + if (mapSettingsRet.count(strKey) == 0) + mapSettingsRet[strKey] = it->value[0]; + mapMultiSettingsRet[strKey].push_back(it->value[0]); + } +} + int GetFilesize(FILE* file) { int nSavePos = ftell(file); @@ -656,9 +690,6 @@ void ShrinkDebugFile() - - - // // "Never go to sea with two chronometers; take one or three." // Our three chronometers are: @@ -701,7 +732,7 @@ void AddTimeData(unsigned int ip, int64 nTime) sort(vTimeOffsets.begin(), vTimeOffsets.end()); int64 nMedian = vTimeOffsets[vTimeOffsets.size()/2]; nTimeOffset = nMedian; - if ((nMedian > 0 ? nMedian : -nMedian) > 36 * 60 * 60) + if ((nMedian > 0 ? nMedian : -nMedian) > 70 * 60) { // Only let other nodes change our clock so far before we // go to the NTP servers -- cgit v1.2.3