aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp52
1 files changed, 25 insertions, 27 deletions
diff --git a/src/net.cpp b/src/net.cpp
index b90eebde4f..9b8dbe11e8 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -3,8 +3,6 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
-#include <stdint.h>
-
#include "headers.h"
#include "irc.h"
#include "db.h"
@@ -46,10 +44,10 @@ bool OpenNetworkConnection(const CAddress& addrConnect);
//
bool fClient = false;
bool fAllowDNS = false;
-uint64_t nLocalServices = (fClient ? 0 : NODE_NETWORK);
+uint64 nLocalServices = (fClient ? 0 : NODE_NETWORK);
CAddress addrLocalHost("0.0.0.0", 0, false, nLocalServices);
static CNode* pnodeLocalHost = NULL;
-uint64_t nLocalHostNonce = 0;
+uint64 nLocalHostNonce = 0;
array<int, 10> vnThreadsRunning;
static SOCKET hListenSocket = INVALID_SOCKET;
@@ -58,9 +56,9 @@ CCriticalSection cs_vNodes;
map<vector<unsigned char>, CAddress> mapAddresses;
CCriticalSection cs_mapAddresses;
map<CInv, CDataStream> mapRelay;
-deque<pair<int64_t, CInv> > vRelayExpiration;
+deque<pair<int64, CInv> > vRelayExpiration;
CCriticalSection cs_mapRelay;
-map<CInv, int64_t> mapAlreadyAskedFor;
+map<CInv, int64> mapAlreadyAskedFor;
// Settings
int fUseProxy = false;
@@ -439,13 +437,13 @@ void ThreadGetMyExternalIP(void* parg)
-bool AddAddress(CAddress addr, int64_t nTimePenalty, CAddrDB *pAddrDB)
+bool AddAddress(CAddress addr, int64 nTimePenalty, CAddrDB *pAddrDB)
{
if (!addr.IsRoutable())
return false;
if (addr.ip == addrLocalHost.ip)
return false;
- addr.nTime = max((int64_t)0, (int64_t)addr.nTime - nTimePenalty);
+ addr.nTime = max((int64)0, (int64)addr.nTime - nTimePenalty);
bool fUpdated = false;
bool fNew = false;
CAddress addrFound = addr;
@@ -471,7 +469,7 @@ bool AddAddress(CAddress addr, int64_t nTimePenalty, CAddrDB *pAddrDB)
fUpdated = true;
}
bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60);
- int64_t nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60);
+ int64 nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60);
if (addrFound.nTime < addr.nTime - nUpdateInterval)
{
// Periodically update most recently seen time
@@ -505,7 +503,7 @@ void AddressCurrentlyConnected(const CAddress& addr)
if (it != mapAddresses.end())
{
CAddress& addrFound = (*it).second;
- int64_t nUpdateInterval = 20 * 60;
+ int64 nUpdateInterval = 20 * 60;
if (addrFound.nTime < GetAdjustedTime() - nUpdateInterval)
{
// Periodically update most recently seen time
@@ -644,7 +642,7 @@ CNode* FindNode(CAddress addr)
return NULL;
}
-CNode* ConnectNode(CAddress addrConnect, int64_t nTimeout)
+CNode* ConnectNode(CAddress addrConnect, int64 nTimeout)
{
if (addrConnect.ip == addrLocalHost.ip)
return NULL;
@@ -732,7 +730,7 @@ void CNode::Cleanup()
void CNode::PushVersion()
{
/// when NTP implemented, change to just nTime = GetAdjustedTime()
- int64_t nTime = (fInbound ? GetAdjustedTime() : GetTime());
+ int64 nTime = (fInbound ? GetAdjustedTime() : GetTime());
CAddress addrYou = (fUseProxy ? CAddress("0.0.0.0") : addr);
CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost);
RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
@@ -744,7 +742,7 @@ void CNode::PushVersion()
-std::map<unsigned int, int64_t> CNode::setBanned;
+std::map<unsigned int, int64> CNode::setBanned;
CCriticalSection CNode::cs_setBanned;
void CNode::ClearBanned()
@@ -757,10 +755,10 @@ bool CNode::IsBanned(unsigned int ip)
bool fResult = false;
CRITICAL_BLOCK(cs_setBanned)
{
- std::map<unsigned int, int64_t>::iterator i = setBanned.find(ip);
+ std::map<unsigned int, int64>::iterator i = setBanned.find(ip);
if (i != setBanned.end())
{
- int64_t t = (*i).second;
+ int64 t = (*i).second;
if (GetTime() < t)
fResult = true;
}
@@ -779,7 +777,7 @@ bool CNode::Misbehaving(int howmuch)
nMisbehavior += howmuch;
if (nMisbehavior >= GetArg("-banscore", 100))
{
- int64_t banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban
+ int64 banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban
CRITICAL_BLOCK(cs_setBanned)
if (setBanned[addr.ip] < banTime)
setBanned[addr.ip] = banTime;
@@ -1405,7 +1403,7 @@ void ThreadOpenConnections2(void* parg)
// Connect to specific addresses
if (mapArgs.count("-connect"))
{
- for (int64_t nLoop = 0;; nLoop++)
+ for (int64 nLoop = 0;; nLoop++)
{
BOOST_FOREACH(string strAddr, mapMultiArgs["-connect"])
{
@@ -1439,7 +1437,7 @@ void ThreadOpenConnections2(void* parg)
}
// Initiate network connections
- int64_t nStart = GetTime();
+ int64 nStart = GetTime();
loop
{
// Limit outbound connections
@@ -1476,7 +1474,7 @@ void ThreadOpenConnections2(void* parg)
// it'll get a pile of addresses with newer timestamps.
// Seed nodes are given a random 'last seen time' of between one and two
// weeks ago.
- const int64_t nOneWeek = 7*24*60*60;
+ const int64 nOneWeek = 7*24*60*60;
CAddress addr;
addr.ip = pnSeed[i];
addr.nTime = GetTime()-GetRand(nOneWeek)-nOneWeek;
@@ -1490,7 +1488,7 @@ void ThreadOpenConnections2(void* parg)
// Choose an address to connect to based on most recently seen
//
CAddress addrConnect;
- int64_t nBest = std::numeric_limits<int64_t>::min();
+ int64 nBest = std::numeric_limits<int64>::min();
// Only connect to one address per a.b.?.? range.
// Do this here so we don't have to critsect vNodes inside mapAddresses critsect.
@@ -1499,7 +1497,7 @@ void ThreadOpenConnections2(void* parg)
BOOST_FOREACH(CNode* pnode, vNodes)
setConnected.insert(pnode->addr.ip & 0x0000ffff);
- int64_t nANow = GetAdjustedTime();
+ int64 nANow = GetAdjustedTime();
CRITICAL_BLOCK(cs_mapAddresses)
{
@@ -1508,11 +1506,11 @@ void ThreadOpenConnections2(void* parg)
const CAddress& addr = item.second;
if (!addr.IsIPv4() || !addr.IsValid() || setConnected.count(addr.ip & 0x0000ffff))
continue;
- int64_t nSinceLastSeen = nANow - addr.nTime;
- int64_t nSinceLastTry = nANow - addr.nLastTry;
+ int64 nSinceLastSeen = nANow - addr.nTime;
+ int64 nSinceLastTry = nANow - addr.nLastTry;
// Randomize the order in a deterministic way, putting the standard port first
- int64_t nRandomizer = (uint64_t)(nStart * 4951 + addr.nLastTry * 9567851 + addr.ip * 7789) % (2 * 60 * 60);
+ int64 nRandomizer = (uint64)(nStart * 4951 + addr.nLastTry * 9567851 + addr.ip * 7789) % (2 * 60 * 60);
if (addr.port != htons(GetDefaultPort()))
nRandomizer += 2 * 60 * 60;
@@ -1526,7 +1524,7 @@ void ThreadOpenConnections2(void* parg)
// 30 days 27 hours
// 90 days 46 hours
// 365 days 93 hours
- int64_t nDelay = (int64_t)(3600.0 * sqrt(fabs((double)nSinceLastSeen) / 3600.0) + nRandomizer);
+ int64 nDelay = (int64)(3600.0 * sqrt(fabs((double)nSinceLastSeen) / 3600.0) + nRandomizer);
// Fast reconnect for one hour after last seen
if (nSinceLastSeen < 60 * 60)
@@ -1547,7 +1545,7 @@ void ThreadOpenConnections2(void* parg)
// If multiple addresses are ready, prioritize by time since
// last seen and time since last tried.
- int64_t nScore = min(nSinceLastTry, (int64_t)24 * 60 * 60) - nSinceLastSeen - nRandomizer;
+ int64 nScore = min(nSinceLastTry, (int64)24 * 60 * 60) - nSinceLastSeen - nRandomizer;
if (nScore > nBest)
{
nBest = nScore;
@@ -1854,7 +1852,7 @@ bool StopNode()
printf("StopNode()\n");
fShutdown = true;
nTransactionsUpdated++;
- int64_t nStart = GetTime();
+ int64 nStart = GetTime();
while (vnThreadsRunning[0] > 0 || vnThreadsRunning[2] > 0 || vnThreadsRunning[3] > 0 || vnThreadsRunning[4] > 0
#ifdef USE_UPNP
|| vnThreadsRunning[5] > 0