Permalink
Browse files

Change to int64_t

  • Loading branch information...
Tranz5 committed Oct 11, 2014
1 parent 8c418a4 commit 66dd15d4762d5c6f94e768c4e4f9094234416275
Showing with 868 additions and 862 deletions.
  1. +1 −1 doc/coding.txt
  2. +17 −17 src/addrman.cpp
  3. +13 −13 src/addrman.h
  4. +2 −2 src/alert.h
  5. +25 −19 src/bignum.h
  6. +3 −3 src/bitcoinrpc.cpp
  7. +3 −3 src/bitcoinrpc.h
  8. +1 −1 src/db.cpp
  9. +2 −2 src/init.cpp
  10. +1 −1 src/irc.cpp
  11. +26 −26 src/kernel.cpp
  12. +3 −3 src/kernel.h
  13. +73 −73 src/main.cpp
  14. +52 −52 src/main.h
  15. +15 −15 src/miner.cpp
  16. +23 −23 src/net.cpp
  17. +33 −33 src/net.h
  18. +2 −2 src/netbase.cpp
  19. +1 −1 src/netbase.h
  20. +1 −1 src/noui.cpp
  21. +1 −1 src/protocol.cpp
  22. +3 −3 src/protocol.h
  23. +1 −1 src/qt/bitcoin.cpp
  24. +5 −5 src/qt/bitcoingui.cpp
  25. +10 −10 src/qt/blockbrowser.cpp
  26. +8 −8 src/qt/blockbrowser.h
  27. +6 −6 src/qt/charitydialog.cpp
  28. +2 −2 src/qt/clientmodel.cpp
  29. +19 −19 src/qt/coincontroldialog.cpp
  30. +2 −2 src/qt/guiutil.cpp
  31. +2 −2 src/qt/optionsmodel.cpp
  32. +8 −8 src/qt/transactiondesc.cpp
  33. +7 −7 src/qt/transactionrecord.cpp
  34. +8 −8 src/qt/transactionrecord.h
  35. +16 −16 src/qt/walletmodel.cpp
  36. +2 −2 src/rpcblockchain.cpp
  37. +1 −1 src/rpcdump.cpp
  38. +4 −4 src/rpcmining.cpp
  39. +2 −2 src/rpcrawtransaction.cpp
  40. +57 −57 src/rpcwallet.cpp
  41. +3 −2 src/script.cpp
  42. +25 −22 src/script.h
  43. +52 −55 src/serialize.h
  44. +4 −4 src/test/DoS_tests.cpp
  45. +2 −2 src/test/accounting_tests.cpp
  46. +4 −4 src/test/bignum_tests.cpp
  47. +1 −1 src/test/script_tests.cpp
  48. +1 −1 src/test/uint160_tests.cpp
  49. +1 −1 src/test/uint256_tests.cpp
  50. +1 −1 src/test/util_tests.cpp
  51. +2 −2 src/test/wallet_tests.cpp
  52. +7 −4 src/ui_interface.h
  53. +31 −32 src/uint256.h
  54. +31 −31 src/util.cpp
  55. +37 −39 src/util.h
  56. +102 −102 src/wallet.cpp
  57. +69 −70 src/wallet.h
  58. +22 −22 src/walletdb.cpp
  59. +10 −10 src/walletdb.h
  60. +2 −2 src/walletview.cpp
@@ -28,7 +28,7 @@ someVariable.
Common types:
n integer number: short, unsigned short, int, unsigned int,
int64, uint64, sometimes char if used as a number
int64_t, uint64_t, sometimes char if used as a number
d double, float
f flag
hash uint256
@@ -11,12 +11,12 @@ int CAddrInfo::GetTriedBucket(const std::vector<unsigned char> &nKey) const
CDataStream ss1(SER_GETHASH, 0);
std::vector<unsigned char> vchKey = GetKey();
ss1 << nKey << vchKey;
uint64 hash1 = Hash(ss1.begin(), ss1.end()).Get64();
uint64_t hash1 = Hash(ss1.begin(), ss1.end()).Get64();
CDataStream ss2(SER_GETHASH, 0);
std::vector<unsigned char> vchGroupKey = GetGroup();
ss2 << nKey << vchGroupKey << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP);
uint64 hash2 = Hash(ss2.begin(), ss2.end()).Get64();
uint64_t hash2 = Hash(ss2.begin(), ss2.end()).Get64();
return hash2 % ADDRMAN_TRIED_BUCKET_COUNT;
}
@@ -26,15 +26,15 @@ int CAddrInfo::GetNewBucket(const std::vector<unsigned char> &nKey, const CNetAd
std::vector<unsigned char> vchGroupKey = GetGroup();
std::vector<unsigned char> vchSourceGroupKey = src.GetGroup();
ss1 << nKey << vchGroupKey << vchSourceGroupKey;
uint64 hash1 = Hash(ss1.begin(), ss1.end()).Get64();
uint64_t hash1 = Hash(ss1.begin(), ss1.end()).Get64();
CDataStream ss2(SER_GETHASH, 0);
ss2 << nKey << vchSourceGroupKey << (hash1 % ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP);
uint64 hash2 = Hash(ss2.begin(), ss2.end()).Get64();
uint64_t hash2 = Hash(ss2.begin(), ss2.end()).Get64();
return hash2 % ADDRMAN_NEW_BUCKET_COUNT;
}
bool CAddrInfo::IsTerrible(int64 nNow) const
bool CAddrInfo::IsTerrible(int64_t nNow) const
{
if (nLastTry && nLastTry >= nNow-60) // never remove things tried the last minute
return false;
@@ -54,12 +54,12 @@ bool CAddrInfo::IsTerrible(int64 nNow) const
return false;
}
double CAddrInfo::GetChance(int64 nNow) const
double CAddrInfo::GetChance(int64_t nNow) const
{
double fChance = 1.0;
int64 nSinceLastSeen = nNow - nTime;
int64 nSinceLastTry = nNow - nLastTry;
int64_t nSinceLastSeen = nNow - nTime;
int64_t nSinceLastTry = nNow - nLastTry;
if (nSinceLastSeen < 0) nSinceLastSeen = 0;
if (nSinceLastTry < 0) nSinceLastTry = 0;
@@ -128,7 +128,7 @@ int CAddrMan::SelectTried(int nKBucket)
// random shuffle the first few elements (using the entire list)
// find the least recently tried among them
int64 nOldest = -1;
int64_t nOldest = -1;
int nOldestPos = -1;
for (unsigned int i = 0; i < ADDRMAN_TRIED_ENTRIES_INSPECT_ON_EVICT && i < vTried.size(); i++)
{
@@ -258,7 +258,7 @@ void CAddrMan::MakeTried(CAddrInfo& info, int nId, int nOrigin)
return;
}
void CAddrMan::Good_(const CService &addr, int64 nTime)
void CAddrMan::Good_(const CService &addr, int64_t nTime)
{
// printf("Good: addr=%s\n", addr.ToString().c_str());
@@ -309,7 +309,7 @@ void CAddrMan::Good_(const CService &addr, int64 nTime)
MakeTried(info, nId, nUBucket);
}
bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64 nTimePenalty)
bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty)
{
if (!addr.IsRoutable())
return false;
@@ -322,9 +322,9 @@ bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64 nTimePen
{
// periodically update nTime
bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60);
int64 nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60);
int64_t nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60);
if (addr.nTime && (!pinfo->nTime || pinfo->nTime < addr.nTime - nUpdateInterval - nTimePenalty))
pinfo->nTime = max((int64)0, addr.nTime - nTimePenalty);
pinfo->nTime = max((int64_t)0, addr.nTime - nTimePenalty);
// add services
pinfo->nServices |= addr.nServices;
@@ -349,7 +349,7 @@ bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64 nTimePen
return false;
} else {
pinfo = Create(addr, source, &nId);
pinfo->nTime = max((int64)0, (int64)pinfo->nTime - nTimePenalty);
pinfo->nTime = max((int64_t)0, (int64_t)pinfo->nTime - nTimePenalty);
// printf("Added %s [nTime=%fhr]\n", pinfo->ToString().c_str(), (GetAdjustedTime() - pinfo->nTime) / 3600.0);
nNew++;
fNew = true;
@@ -367,7 +367,7 @@ bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64 nTimePen
return fNew;
}
void CAddrMan::Attempt_(const CService &addr, int64 nTime)
void CAddrMan::Attempt_(const CService &addr, int64_t nTime)
{
CAddrInfo *pinfo = Find(addr);
@@ -506,7 +506,7 @@ void CAddrMan::GetAddr_(std::vector<CAddress> &vAddr)
}
}
void CAddrMan::Connected_(const CService &addr, int64 nTime)
void CAddrMan::Connected_(const CService &addr, int64_t nTime)
{
CAddrInfo *pinfo = Find(addr);
@@ -521,7 +521,7 @@ void CAddrMan::Connected_(const CService &addr, int64 nTime)
return;
// update info
int64 nUpdateInterval = 20 * 60;
int64_t nUpdateInterval = 20 * 60;
if (nTime - info.nTime > nUpdateInterval)
info.nTime = nTime;
}
@@ -24,10 +24,10 @@ class CAddrInfo : public CAddress
CNetAddr source;
// last successful connection by us
int64 nLastSuccess;
int64_t nLastSuccess;
// last try whatsoever by us:
// int64 CAddress::nLastTry
// int64_t CAddress::nLastTry
// connection attempts since last successful attempt
int nAttempts;
@@ -86,10 +86,10 @@ class CAddrInfo : public CAddress
}
// Determine whether the statistics about this entry are bad enough so that it can just be deleted
bool IsTerrible(int64 nNow = GetAdjustedTime()) const;
bool IsTerrible(int64_t nNow = GetAdjustedTime()) const;
// Calculate the relative chance this entry should be given when selecting nodes to connect to
double GetChance(int64 nNow = GetAdjustedTime()) const;
double GetChance(int64_t nNow = GetAdjustedTime()) const;
};
@@ -220,13 +220,13 @@ class CAddrMan
void MakeTried(CAddrInfo& info, int nId, int nOrigin);
// Mark an entry "good", possibly moving it from "new" to "tried".
void Good_(const CService &addr, int64 nTime);
void Good_(const CService &addr, int64_t nTime);
// Add an entry to the "new" table.
bool Add_(const CAddress &addr, const CNetAddr& source, int64 nTimePenalty);
bool Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty);
// Mark an entry as attempted to connect.
void Attempt_(const CService &addr, int64 nTime);
void Attempt_(const CService &addr, int64_t nTime);
// Select an address to connect to.
// nUnkBias determines how much to favor new addresses over tried ones (min=0, max=100)
@@ -241,7 +241,7 @@ class CAddrMan
void GetAddr_(std::vector<CAddress> &vAddr);
// Mark an entry as currently-connected-to.
void Connected_(const CService &addr, int64 nTime);
void Connected_(const CService &addr, int64_t nTime);
public:
@@ -409,7 +409,7 @@ class CAddrMan
}
// Add a single address.
bool Add(const CAddress &addr, const CNetAddr& source, int64 nTimePenalty = 0)
bool Add(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty = 0)
{
bool fRet = false;
{
@@ -424,7 +424,7 @@ class CAddrMan
}
// Add multiple addresses.
bool Add(const std::vector<CAddress> &vAddr, const CNetAddr& source, int64 nTimePenalty = 0)
bool Add(const std::vector<CAddress> &vAddr, const CNetAddr& source, int64_t nTimePenalty = 0)
{
int nAdd = 0;
{
@@ -440,7 +440,7 @@ class CAddrMan
}
// Mark an entry as accessible.
void Good(const CService &addr, int64 nTime = GetAdjustedTime())
void Good(const CService &addr, int64_t nTime = GetAdjustedTime())
{
{
LOCK(cs);
@@ -451,7 +451,7 @@ class CAddrMan
}
// Mark an entry as connection attempted to.
void Attempt(const CService &addr, int64 nTime = GetAdjustedTime())
void Attempt(const CService &addr, int64_t nTime = GetAdjustedTime())
{
{
LOCK(cs);
@@ -489,7 +489,7 @@ class CAddrMan
}
// Mark an entry as currently-connected-to.
void Connected(const CService &addr, int64 nTime = GetAdjustedTime())
void Connected(const CService &addr, int64_t nTime = GetAdjustedTime())
{
{
LOCK(cs);
@@ -24,8 +24,8 @@ class CUnsignedAlert
{
public:
int nVersion;
int64 nRelayUntil; // when newer nodes stop relaying to newer nodes
int64 nExpiration;
int64_t nRelayUntil; // when newer nodes stop relaying to newer nodes
int64_t nExpiration;
int nID;
int nCancel;
std::set<int> setCancel;
@@ -2,14 +2,20 @@
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_BIGNUM_H
#define BITCOIN_BIGNUM_H
#include "serialize.h"
#include "uint256.h"
#include "version.h"
#include <openssl/bn.h>
#include <stdexcept>
#include <vector>
#include <openssl/bn.h>
#include "util.h" // for uint64
#include <stdint.h>
/** Errors thrown by the bignum class */
class bignum_error : public std::runtime_error
@@ -79,17 +85,17 @@ class CBigNum : public BIGNUM
}
// CBigNum(char n) is not portable. Use 'signed char' or 'unsigned char'.
CBigNum(signed char n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(short n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(int n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(long n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(int64 n) { BN_init(this); setint64(n); }
CBigNum(unsigned char n) { BN_init(this); setulong(n); }
CBigNum(unsigned short n) { BN_init(this); setulong(n); }
CBigNum(unsigned int n) { BN_init(this); setulong(n); }
CBigNum(unsigned long n) { BN_init(this); setulong(n); }
CBigNum(uint64 n) { BN_init(this); setuint64(n); }
explicit CBigNum(uint256 n) { BN_init(this); setuint256(n); }
CBigNum(signed char n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(short n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(int n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(long n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(long long n) { BN_init(this); setint64(n); }
CBigNum(unsigned char n) { BN_init(this); setulong(n); }
CBigNum(unsigned short n) { BN_init(this); setulong(n); }
CBigNum(unsigned int n) { BN_init(this); setulong(n); }
CBigNum(unsigned long n) { BN_init(this); setulong(n); }
CBigNum(unsigned long long n) { BN_init(this); setuint64(n); }
explicit CBigNum(uint256 n) { BN_init(this); setuint256(n); }
explicit CBigNum(const std::vector<unsigned char>& vch)
{
@@ -122,14 +128,14 @@ class CBigNum : public BIGNUM
return (n > (unsigned long)std::numeric_limits<int>::max() ? std::numeric_limits<int>::min() : -(int)n);
}
void setint64(int64 sn)
void setint64(int64_t sn)
{
unsigned char pch[sizeof(sn) + 6];
unsigned char* p = pch + 4;
bool fNegative;
uint64 n;
uint64_t n;
if (sn < (int64)0)
if (sn < (int64_t)0)
{
// Since the minimum signed integer cannot be represented as positive so long as its type is signed, and it's not well-defined what happens if you make it unsigned before negating it, we instead increment the negative integer by 1, convert it, then increment the (now positive) unsigned integer by 1 to compensate
n = -(sn + 1);
@@ -165,7 +171,7 @@ class CBigNum : public BIGNUM
BN_mpi2bn(pch, p - pch, this);
}
uint64 getuint64()
uint64_t getuint64()
{
unsigned int nSize = BN_bn2mpi(this, NULL);
if (nSize < 4)
@@ -174,13 +180,13 @@ class CBigNum : public BIGNUM
BN_bn2mpi(this, &vch[0]);
if (vch.size() > 4)
vch[4] &= 0x7f;
uint64 n = 0;
uint64_t n = 0;
for (unsigned int i = 0, j = vch.size()-1; i < sizeof(n) && j >= 4; i++, j--)
((unsigned char*)&n)[i] = vch[j];
return n;
}
void setuint64(uint64 n)
void setuint64(uint64_t n)
{
unsigned char pch[sizeof(n) + 6];
unsigned char* p = pch + 4;
@@ -94,18 +94,18 @@ void RPCTypeCheck(const Object& o,
}
}
int64 AmountFromValue(const Value& value)
int64_t AmountFromValue(const Value& value)
{
double dAmount = value.get_real();
if (dAmount <= 0.0 || dAmount > MAX_MONEY)
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
int64 nAmount = roundint64(dAmount * COIN);
int64_t nAmount = roundint64(dAmount * COIN);
if (!MoneyRange(nAmount))
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
return nAmount;
}
Value ValueFromAmount(int64 amount)
Value ValueFromAmount(int64_t amount)
{
return (double)amount / (double)COIN;
}
@@ -126,9 +126,9 @@ class CRPCTable
extern const CRPCTable tableRPC;
extern int64 nWalletUnlockTime;
extern int64 AmountFromValue(const json_spirit::Value& value);
extern json_spirit::Value ValueFromAmount(int64 amount);
extern int64_t nWalletUnlockTime;
extern int64_t AmountFromValue(const json_spirit::Value& value);
extern json_spirit::Value ValueFromAmount(int64_t amount);
extern double GetDifficulty(const CBlockIndex* blockindex = NULL);
extern double GetPoWMHashPS(const CBlockIndex* blockindex = NULL);
extern double GetPoSKernelPS(const CBlockIndex* blockindex = NULL);
@@ -471,7 +471,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
void CDBEnv::Flush(bool fShutdown)
{
int64 nStart = GetTimeMillis();
int64_t nStart = GetTimeMillis();
// Flush log data to the actual data file
// on all files that are not in use
printf("Flush(%s)%s\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started");
@@ -640,7 +640,7 @@ bool AppInit2()
if (fDaemon)
fprintf(stdout, "HoboNickels server starting\n");
int64 nStart;
int64_t nStart;
// ********************************************************* Step 5: verify database integrity
@@ -880,7 +880,7 @@ bool AppInit2()
if (mapArgs.count("-reservebalance"))
{
int64 nReserveBalance = 0;
int64_t nReserveBalance = 0;
if (!ParseMoney(mapArgs["-reservebalance"], nReserveBalance))
InitError(_("Invalid amount for -reservebalance=<amount>"));
else
Oops, something went wrong.

0 comments on commit 66dd15d

Please sign in to comment.