aboutsummaryrefslogtreecommitdiff
path: root/util.cpp
diff options
context:
space:
mode:
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-11-13 01:23:08 +0000
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-11-13 01:23:08 +0000
commit70e79525c97c33a5fca8674d47d86cc2b7ae197a (patch)
tree7427ce9b17468ed4a9dec82b380c2dd40a5332ca /util.cpp
parent956468c29adcbff83ab7c2e52d91f8e87b704853 (diff)
downloadbitcoin-70e79525c97c33a5fca8674d47d86cc2b7ae197a.tar.xz
monitor ThreadSocketHandler and terminate and restart if hung, convert _beginthread to CreateThread wrapper, disconnect inactive connections, ping, break up long messages to speed up initial download, better priorities for initiating connections, track how many nodes have requested our blocks and transactions, status #/offline and warning message on unsent blocks, minimize on close as separate option -- linux-test5
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@38 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'util.cpp')
-rw-r--r--util.cpp48
1 files changed, 23 insertions, 25 deletions
diff --git a/util.cpp b/util.cpp
index 4a5b983d22..7a947730ce 100644
--- a/util.cpp
+++ b/util.cpp
@@ -85,14 +85,14 @@ void RandAddSeed()
void RandAddSeedPerfmon()
{
-#ifdef __WXMSW__
- // Don't need this on Linux, OpenSSL automatically uses /dev/urandom
// This can take up to 2 seconds, so only do it every 10 minutes
static int64 nLastPerfmon;
if (GetTime() < nLastPerfmon + 10 * 60)
return;
nLastPerfmon = GetTime();
+#ifdef __WXMSW__
+ // Don't need this on Linux, OpenSSL automatically uses /dev/urandom
// Seed with the entire set of perfmon data
unsigned char pdata[250000];
memset(pdata, 0, sizeof(pdata));
@@ -109,9 +109,30 @@ void RandAddSeedPerfmon()
printf("%s RandAddSeed() %d bytes\n", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str(), nSize);
}
+#else
+ printf("%s RandAddSeed()\n", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
#endif
}
+uint64 GetRand(uint64 nMax)
+{
+ if (nMax == 0)
+ return 0;
+
+ // The range of the random source must be a multiple of the modulus
+ // to give every possible output value an equal possibility
+ uint64 nRange = (UINT64_MAX / nMax) * nMax;
+ uint64 nRand = 0;
+ do
+ RAND_bytes((unsigned char*)&nRand, sizeof(nRand));
+ while (nRand >= nRange);
+ return (nRand % nMax);
+}
+
+
+
+
+
@@ -449,28 +470,6 @@ string GetDataDir()
-uint64 GetRand(uint64 nMax)
-{
- if (nMax == 0)
- return 0;
-
- // The range of the random source must be a multiple of the modulus
- // to give every possible output value an equal possibility
- uint64 nRange = (_UI64_MAX / nMax) * nMax;
- uint64 nRand = 0;
- do
- RAND_bytes((unsigned char*)&nRand, sizeof(nRand));
- while (nRand >= nRange);
- return (nRand % nMax);
-}
-
-
-
-
-
-
-
-
//
@@ -483,7 +482,6 @@ uint64 GetRand(uint64 nMax)
// note: NTP isn't implemented yet, so until then we just use the median
// of other nodes clocks to correct ours.
//
-
int64 GetTime()
{
return time(NULL);