aboutsummaryrefslogtreecommitdiff
path: root/util.cpp
diff options
context:
space:
mode:
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-07-25 16:45:21 +0000
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-07-25 16:45:21 +0000
commit3b7cd5d89a226426df9c723d1f9ddfe08b7d1def (patch)
treecb956c8dd87690dcd9e5d554286d39edbb199c32 /util.cpp
parente8bff10f07b80d820545661cee9337d8664a64cb (diff)
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
Diffstat (limited to 'util.cpp')
-rw-r--r--util.cpp41
1 files changed, 36 insertions, 5 deletions
diff --git a/util.cpp b/util.cpp
index 4ddc5250ea..5d3728a135 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<string, string>& mapSettingsRet,
+ map<string, vector<string> >& mapMultiSettingsRet)
+{
+ namespace fs = boost::filesystem;
+ namespace pod = boost::program_options::detail;
+
+ fs::ifstream streamConfig(GetConfigFile());
+ if (!streamConfig.good())
+ return;
+
+ set<string> 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