Cleanup code using forward declarations.

Use misc methods of avoiding unnecesary header includes.
Replace int typedefs with int##_t from stdint.h.
Replace PRI64[xdu] with PRI[xdu]64 from inttypes.h.
Normalize QT_VERSION ifs where possible.
Resolve some indirect dependencies as direct ones.
Remove extern declarations from .cpp files.
This commit is contained in:
Brandon Dahler 2013-04-13 00:13:08 -05:00
parent 7c4c207be8
commit 51ed9ec971
177 changed files with 2084 additions and 1681 deletions

View file

@ -151,7 +151,7 @@ PKG_PROG_PKG_CONFIG
## compatibility with the legacy buildsystem.
##
CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter"
CPPFLAGS="$CPPFLAGS -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO"
CPPFLAGS="$CPPFLAGS -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS"
AC_LANG_PUSH([C++])

View file

@ -57,7 +57,10 @@ child = Popen([XGETTEXT,'--output=-','-n','--keyword=_'] + files, stdout=PIPE)
messages = parse_po(out)
f = open(OUT_CPP, 'w')
f.write("""#include <QtGlobal>
f.write("""
#include <QtGlobal>
// Automatically generated by extract_strings.py
#ifdef __GNUC__
#define UNUSED __attribute__((unused))
@ -70,5 +73,5 @@ messages.sort(key=operator.itemgetter(0))
for (msgid, msgstr) in messages:
if msgid != EMPTY:
f.write('QT_TRANSLATE_NOOP("bitcoin-core", %s),\n' % ('\n'.join(msgid)))
f.write('};')
f.write('};\n')
f.close()

View file

@ -16,7 +16,7 @@ BITCOIN_CORE_H = addrman.h alert.h allocators.h base58.h bignum.h \
bitcoinrpc.h bloom.h chainparams.h checkpoints.h checkqueue.h \
clientversion.h compat.h core.h crypter.h db.h hash.h init.h \
key.h keystore.h leveldbwrapper.h limitedmap.h main.h miner.h mruset.h \
netbase.h net.h protocol.h script.h serialize.h sync.h threadsafety.h \
netbase.h net.h noui.h protocol.h script.h serialize.h sync.h threadsafety.h \
txdb.h txmempool.h ui_interface.h uint256.h util.h version.h walletdb.h wallet.h
JSON_H = json/json_spirit.h json/json_spirit_error_position.h \

View file

@ -3,7 +3,9 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "addrman.h"
#include "hash.h"
#include "serialize.h"
using namespace std;
@ -12,12 +14,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;
}
@ -27,15 +29,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;
@ -55,12 +57,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;
@ -129,7 +131,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++)
{
@ -259,7 +261,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)
{
int nId;
CAddrInfo *pinfo = Find(addr, &nId);
@ -308,7 +310,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;
@ -321,9 +323,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;
@ -348,7 +350,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);
nNew++;
fNew = true;
}
@ -365,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);
@ -504,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);
@ -519,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;
}

View file

@ -1,21 +1,22 @@
// Copyright (c) 2012 Pieter Wuille
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef _BITCOIN_ADDRMAN
#define _BITCOIN_ADDRMAN 1
#include "netbase.h"
#include "protocol.h"
#include "util.h"
#include "sync.h"
#include "util.h"
#include <map>
#include <set>
#include <stdint.h>
#include <vector>
#include <openssl/rand.h>
/** Extended statistics about a CAddress */
class CAddrInfo : public CAddress
{
@ -24,10 +25,10 @@ private:
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 +87,10 @@ public:
}
// 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 +221,13 @@ protected:
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 +242,7 @@ protected:
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 +410,7 @@ public:
}
// 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 +425,7 @@ public:
}
// 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 +441,7 @@ public:
}
// 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 +452,7 @@ public:
}
// 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 +490,7 @@ public:
}
// 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);

View file

@ -2,17 +2,20 @@
// Alert system
//
#include "alert.h"
#include "key.h"
#include "net.h"
#include "ui_interface.h"
#include "util.h"
#include <algorithm>
#include <inttypes.h>
#include <map>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/foreach.hpp>
#include <map>
#include "alert.h"
#include "key.h"
#include "net.h"
#include "sync.h"
#include "ui_interface.h"
using namespace std;
@ -48,8 +51,8 @@ std::string CUnsignedAlert::ToString() const
return strprintf(
"CAlert(\n"
" nVersion = %d\n"
" nRelayUntil = %"PRI64d"\n"
" nExpiration = %"PRI64d"\n"
" nRelayUntil = %"PRId64"\n"
" nExpiration = %"PRId64"\n"
" nID = %d\n"
" nCancel = %d\n"
" setCancel = %s\n"

View file

@ -6,13 +6,20 @@
#ifndef _BITCOINALERT_H_
#define _BITCOINALERT_H_ 1
#include "serialize.h"
#include "sync.h"
#include <map>
#include <set>
#include <stdint.h>
#include <string>
#include "uint256.h"
#include "util.h"
class CAlert;
class CNode;
class uint256;
extern std::map<uint256, CAlert> mapAlerts;
extern CCriticalSection cs_mapAlerts;
/** Alerts are for notifying old versions if they become too obsolete and
* need to upgrade. The message is displayed in the status bar.
@ -24,8 +31,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;

View file

@ -2,17 +2,18 @@
// Copyright (c) 2009-2013 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_ALLOCATORS_H
#define BITCOIN_ALLOCATORS_H
#include <string.h>
#include <map>
#include <string>
#include <string.h>
#include <boost/thread/mutex.hpp>
#include <boost/thread/once.hpp>
#include <map>
#include <openssl/crypto.h> // for OPENSSL_cleanse()
/**
* Thread-safe class to keep track of locked (ie, non-swappable) memory pages.
*

View file

@ -3,7 +3,6 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
//
// Why base-58 instead of standard base-64 encoding?
// - Don't want 0OIl characters that look the same in some fonts and
@ -15,14 +14,18 @@
#ifndef BITCOIN_BASE58_H
#define BITCOIN_BASE58_H
#include "bignum.h"
#include "chainparams.h"
#include "hash.h"
#include "key.h"
#include "script.h"
#include "uint256.h"
#include <string>
#include <vector>
#include "chainparams.h"
#include "bignum.h"
#include "key.h"
#include "script.h"
#include "allocators.h"
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/static_visitor.hpp>
static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";

View file

@ -2,14 +2,19 @@
// Copyright (c) 2009-2013 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 <stdexcept>
#include <vector>
#include <openssl/bn.h>
#include "serialize.h"
#include "uint256.h"
#include "version.h"
#include "util.h" // for uint64
#include <stdexcept>
#include <stdint.h>
#include <vector>
#include <openssl/bn.h>
/** Errors thrown by the bignum class */
class bignum_error : public std::runtime_error
@ -79,17 +84,17 @@ public:
}
//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 +127,14 @@ public:
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,
@ -167,7 +172,7 @@ public:
BN_mpi2bn(pch, p - pch, this);
}
void setuint64(uint64 n)
void setuint64(uint64_t n)
{
unsigned char pch[sizeof(n) + 6];
unsigned char* p = pch + 4;

View file

@ -8,6 +8,8 @@
#include "bitcoinrpc.h"
#include "ui_interface.h" /* for _(...) */
#include <boost/filesystem/operations.hpp>
//////////////////////////////////////////////////////////////////////////////
//
// Start

View file

@ -3,12 +3,17 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "ui_interface.h"
#include "init.h"
#include "util.h"
#include "main.h"
#include "bitcoinrpc.h"
#include "init.h"
#include "main.h"
#include "noui.h"
#include "ui_interface.h"
#include "util.h"
#include <boost/algorithm/string/predicate.hpp>
#include <boost/filesystem.hpp>
void DetectShutdownThread(boost::thread_group* threadGroup)
{
@ -138,7 +143,6 @@ bool AppInit(int argc, char* argv[])
return fRet;
}
extern void noui_connect();
int main(int argc, char* argv[])
{
bool fRet = false;

View file

@ -3,30 +3,27 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "chainparams.h"
#include "main.h"
#include "wallet.h"
#include "init.h"
#include "util.h"
#include "sync.h"
#include "ui_interface.h"
#include "base58.h"
#include "bitcoinrpc.h"
#include "db.h"
#include "base58.h"
#include "init.h"
#include "main.h"
#include "util.h"
#include "wallet.h"
#include <stdint.h>
#include <boost/algorithm/string.hpp>
#include <boost/asio.hpp>
#include <boost/asio/ip/v6_only.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/bind.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/foreach.hpp>
#include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/shared_ptr.hpp>
#include <list>
#include "json/json_spirit_writer_template.h"
using namespace std;
using namespace boost;
@ -89,18 +86,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 > 21000000.0)
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;
}
@ -897,7 +894,7 @@ void RPCRunHandler(const boost::system::error_code& err, boost::function<void(vo
func();
}
void RPCRunLater(const std::string& name, boost::function<void(void)> func, int64 nSeconds)
void RPCRunLater(const std::string& name, boost::function<void(void)> func, int64_t nSeconds)
{
assert(rpc_io_service != NULL);

View file

@ -6,19 +6,20 @@
#ifndef _BITCOINRPC_H_
#define _BITCOINRPC_H_ 1
#include <string>
#include "uint256.h"
#include <list>
#include <map>
#include <stdint.h>
#include <string>
#include "json/json_spirit_reader_template.h"
#include "json/json_spirit_utils.h"
#include "json/json_spirit_writer_template.h"
class CBlockIndex;
class CReserveKey;
#include "json/json_spirit_reader_template.h"
#include "json/json_spirit_writer_template.h"
#include "json/json_spirit_utils.h"
#include "util.h"
// HTTP status codes
enum HTTPStatusCode
{
@ -96,7 +97,7 @@ void RPCTypeCheck(const json_spirit::Object& o,
Run func nSeconds from now. Uses boost deadline timers.
Overrides previous timer <name> (if any).
*/
void RPCRunLater(const std::string& name, boost::function<void(void)> func, int64 nSeconds);
void RPCRunLater(const std::string& name, boost::function<void(void)> func, int64_t nSeconds);
typedef json_spirit::Value(*rpcfn_type)(const json_spirit::Array& params, bool fHelp);
@ -146,9 +147,9 @@ extern std::vector<unsigned char> ParseHexO(const json_spirit::Object& o, std::s
extern void InitRPCMining();
extern void ShutdownRPCMining();
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 std::string HexBits(unsigned int nBits);
extern std::string HelpRequiringPassphrase();

View file

@ -1,13 +1,15 @@
// Copyright (c) 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.
#include <math.h>
#include <stdlib.h>
#include "bloom.h"
#include "core.h"
#include "script.h"
#include <math.h>
#include <stdlib.h>
#define LN2SQUARED 0.4804530139182014246671025263266649717305529515945455
#define LN2 0.6931471805599453094172321214581765680755001343602552

View file

@ -1,16 +1,17 @@
// Copyright (c) 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_BLOOM_H
#define BITCOIN_BLOOM_H
#include <vector>
#include "uint256.h"
#include "serialize.h"
#include <vector>
class COutPoint;
class CTransaction;
class uint256;
// 20,000 items with fp rate < 0.1% or 10,000 items and <0.0001%
static const unsigned int MAX_BLOOM_FILTER_SIZE = 36000; // bytes

View file

@ -3,9 +3,9 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "assert.h"
#include "chainparams.h"
#include "assert.h"
#include "core.h"
#include "protocol.h"
#include "util.h"
@ -158,7 +158,7 @@ public:
// 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 nOneWeek = 7*24*60*60;
const int64_t nOneWeek = 7*24*60*60;
struct in_addr ip;
memcpy(&ip, &pnSeed[i], sizeof(ip));
CAddress addr(CService(ip, GetDefaultPort()));

View file

@ -8,7 +8,6 @@
#include "bignum.h"
#include "uint256.h"
#include "util.h"
#include <vector>

View file

@ -2,14 +2,16 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <boost/assign/list_of.hpp> // for 'map_list_of()'
#include <boost/foreach.hpp>
#include "checkpoints.h"
#include "main.h"
#include "uint256.h"
#include <stdint.h>
#include <boost/assign/list_of.hpp> // for 'map_list_of()'
#include <boost/foreach.hpp>
namespace Checkpoints
{
typedef std::map<int, uint256> MapCheckpoints;
@ -23,8 +25,8 @@ namespace Checkpoints
struct CCheckpointData {
const MapCheckpoints *mapCheckpoints;
int64 nTimeLastCheckpoint;
int64 nTransactionsLastCheckpoint;
int64_t nTimeLastCheckpoint;
int64_t nTransactionsLastCheckpoint;
double fTransactionsPerDay;
};
@ -105,7 +107,7 @@ namespace Checkpoints
if (pindex==NULL)
return 0.0;
int64 nNow = time(NULL);
int64_t nNow = time(NULL);
double fWorkBefore = 0.0; // Amount of work done before pindex
double fWorkAfter = 0.0; // Amount of work left after pindex (estimated)

View file

@ -1,13 +1,14 @@
// Copyright (c) 2009-2013 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_CHECKPOINT_H
#define BITCOIN_CHECKPOINT_H
#include <map>
class uint256;
class CBlockIndex;
class uint256;
/** Block-chain checkpoints are compiled-in sanity checks.
* They are updated every release or three.

View file

@ -1,16 +1,17 @@
// Copyright (c) 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 CHECKQUEUE_H
#define CHECKQUEUE_H
#include <boost/foreach.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/condition_variable.hpp>
#include <vector>
#include <algorithm>
#include <vector>
#include <boost/foreach.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/mutex.hpp>
template<typename T> class CCheckQueueControl;

View file

@ -2,6 +2,7 @@
// Copyright (c) 2009-2013 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_COMPAT_H
#define _BITCOIN_COMPAT_H
@ -18,17 +19,24 @@
#undef FD_SETSIZE // prevent redefinition compiler warning
#endif
#define FD_SETSIZE 1024 // max number of fds in fd_set
#include <winsock2.h>
#include <winsock2.h> // Must be included before mswsock.h and windows.h
#include <mswsock.h>
#include <windows.h>
#include <ws2tcpip.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/fcntl.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <net/if.h>
#include <netinet/in.h>
#include <ifaddrs.h>
#include <limits.h>
#include <net/if.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/fcntl.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#endif
#ifdef WIN32

View file

@ -4,8 +4,11 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "core.h"
#include "util.h"
#include <stdint.h>
std::string COutPoint::ToString() const
{
return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10).c_str(), n);
@ -50,7 +53,7 @@ void CTxIn::print() const
LogPrintf("%s\n", ToString().c_str());
}
CTxOut::CTxOut(int64 nValueIn, CScript scriptPubKeyIn)
CTxOut::CTxOut(int64_t nValueIn, CScript scriptPubKeyIn)
{
nValue = nValueIn;
scriptPubKey = scriptPubKeyIn;
@ -63,7 +66,7 @@ uint256 CTxOut::GetHash() const
std::string CTxOut::ToString() const
{
return strprintf("CTxOut(nValue=%"PRI64d".%08"PRI64d", scriptPubKey=%s)", nValue / COIN, nValue % COIN, scriptPubKey.ToString().substr(0,30).c_str());
return strprintf("CTxOut(nValue=%"PRId64".%08"PRId64", scriptPubKey=%s)", nValue / COIN, nValue % COIN, scriptPubKey.ToString().substr(0,30).c_str());
}
void CTxOut::print() const
@ -135,7 +138,7 @@ void CTransaction::print() const
// * if e==9, we only know the resulting number is not zero, so output 1 + 10*(n - 1) + 9
// (this is decodable, as d is in [1-9] and e is in [0-9])
uint64 CTxOutCompressor::CompressAmount(uint64 n)
uint64_t CTxOutCompressor::CompressAmount(uint64_t n)
{
if (n == 0)
return 0;
@ -154,7 +157,7 @@ uint64 CTxOutCompressor::CompressAmount(uint64 n)
}
}
uint64 CTxOutCompressor::DecompressAmount(uint64 x)
uint64_t CTxOutCompressor::DecompressAmount(uint64_t x)
{
// x = 0 OR x = 1+10*(9*n + d - 1) + e OR x = 1+10*(n - 1) + 9
if (x == 0)
@ -163,7 +166,7 @@ uint64 CTxOutCompressor::DecompressAmount(uint64 x)
// x = 10*(9*n + d - 1) + e
int e = x % 10;
x /= 10;
uint64 n = 0;
uint64_t n = 0;
if (e < 9) {
// x = 9*n + d - 1
int d = (x % 9) + 1;

View file

@ -2,14 +2,17 @@
// Copyright (c) 2009-2013 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_CORE_H
#define BITCOIN_CORE_H
#include "uint256.h"
#include "serialize.h"
#include "script.h"
#include "serialize.h"
#include "uint256.h"
#include <stdio.h>
#include <stdint.h>
#include <boost/foreach.hpp>
class CTransaction;
@ -114,7 +117,7 @@ public:
class CTxOut
{
public:
int64 nValue;
int64_t nValue;
CScript scriptPubKey;
CTxOut()
@ -122,7 +125,7 @@ public:
SetNull();
}
CTxOut(int64 nValueIn, CScript scriptPubKeyIn);
CTxOut(int64_t nValueIn, CScript scriptPubKeyIn);
IMPLEMENT_SERIALIZE
(
@ -143,7 +146,7 @@ public:
uint256 GetHash() const;
bool IsDust(int64 nMinRelayTxFee) const
bool IsDust(int64_t nMinRelayTxFee) const
{
// "Dust" is defined in terms of CTransaction::nMinRelayTxFee,
// which has units satoshis-per-kilobyte.
@ -178,8 +181,8 @@ public:
class CTransaction
{
public:
static int64 nMinTxFee;
static int64 nMinRelayTxFee;
static int64_t nMinTxFee;
static int64_t nMinRelayTxFee;
static const int CURRENT_VERSION=1;
int nVersion;
std::vector<CTxIn> vin;
@ -246,17 +249,17 @@ private:
CTxOut &txout;
public:
static uint64 CompressAmount(uint64 nAmount);
static uint64 DecompressAmount(uint64 nAmount);
static uint64_t CompressAmount(uint64_t nAmount);
static uint64_t DecompressAmount(uint64_t nAmount);
CTxOutCompressor(CTxOut &txoutIn) : txout(txoutIn) { }
IMPLEMENT_SERIALIZE(({
if (!fRead) {
uint64 nVal = CompressAmount(txout.nValue);
uint64_t nVal = CompressAmount(txout.nValue);
READWRITE(VARINT(nVal));
} else {
uint64 nVal = 0;
uint64_t nVal = 0;
READWRITE(VARINT(nVal));
txout.nValue = DecompressAmount(nVal);
}
@ -599,9 +602,9 @@ public:
uint256 GetHash() const;
int64 GetBlockTime() const
int64_t GetBlockTime() const
{
return (int64)nTime;
return (int64_t)nTime;
}
};

View file

@ -2,12 +2,13 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "crypter.h"
#include <string>
#include <vector>
#include <openssl/aes.h>
#include <openssl/evp.h>
#include <vector>
#include <string>
#include "crypter.h"
bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::vector<unsigned char>& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod)
{

View file

@ -1,13 +1,15 @@
// Copyright (c) 2009-2013 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 __CRYPTER_H__
#define __CRYPTER_H__
#include "allocators.h" /* for SecureString */
#include "key.h"
#include "allocators.h"
#include "serialize.h"
class uint256;
const unsigned int WALLET_CRYPTO_KEY_SIZE = 32;
const unsigned int WALLET_CRYPTO_SALT_SIZE = 8;

View file

@ -3,19 +3,24 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "chainparams.h"
#include "db.h"
#include "util.h"
#include "hash.h"
#include "addrman.h"
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <openssl/rand.h>
#include "hash.h"
#include "protocol.h"
#include "util.h"
#include <inttypes.h>
#include <stdint.h>
#ifndef WIN32
#include "sys/stat.h"
#include <sys/stat.h>
#endif
#include <boost/filesystem.hpp>
#include <boost/version.hpp>
#include <openssl/rand.h>
using namespace std;
using namespace boost;
@ -430,7 +435,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
LogPrint("db", "Flush(%s)%s\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started");
@ -459,7 +464,7 @@ void CDBEnv::Flush(bool fShutdown)
else
mi++;
}
LogPrint("db", "DBFlush(%s)%s ended %15"PRI64d"ms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started", GetTimeMillis() - nStart);
LogPrint("db", "DBFlush(%s)%s ended %15"PRId64"ms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started", GetTimeMillis() - nStart);
if (fShutdown)
{
char** listp;

View file

@ -2,30 +2,29 @@
// Copyright (c) 2009-2013 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_DB_H
#define BITCOIN_DB_H
#include "sync.h"
#include "serialize.h"
#include "sync.h"
#include "version.h"
#include <map>
#include <string>
#include <vector>
#include <boost/filesystem.hpp>
#include <boost/filesystem/path.hpp>
#include <db_cxx.h>
class CAddrMan;
struct CBlockLocator;
class CDiskBlockIndex;
class CMasterKey;
class COutPoint;
class CWallet;
extern unsigned int nWalletDBUpdated;
void ThreadFlushWalletDB(const std::string& strWalletFile);
bool BackupWallet(const CWallet& wallet, const std::string& strDest);
class CDBEnv

View file

@ -2,16 +2,19 @@
// Copyright (c) 2009-2013 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_HASH_H
#define BITCOIN_HASH_H
#include "uint256.h"
#include "serialize.h"
#include "uint256.h"
#include "version.h"
#include <openssl/sha.h>
#include <openssl/ripemd.h>
#include <vector>
#include <openssl/ripemd.h>
#include <openssl/sha.h>
template<typename T1>
inline uint256 Hash(const T1 pbegin, const T1 pend)
{

View file

@ -8,29 +8,30 @@
#endif
#include "init.h"
#include "main.h"
#include "core.h"
#include "chainparams.h"
#include "txdb.h"
#include "walletdb.h"
#include "bitcoinrpc.h"
#include "net.h"
#include "util.h"
#include "miner.h"
#include "ui_interface.h"
#include "checkpoints.h"
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/interprocess/sync/file_lock.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <openssl/crypto.h>
#include "addrman.h"
#include "bitcoinrpc.h"
#include "checkpoints.h"
#include "miner.h"
#include "net.h"
#include "txdb.h"
#include "ui_interface.h"
#include "util.h"
#include "wallet.h"
#include "walletdb.h"
#include <inttypes.h>
#include <stdint.h>
#ifndef WIN32
#include <signal.h>
#endif
#include <boost/algorithm/string/predicate.hpp>
#include <boost/filesystem.hpp>
#include <boost/interprocess/sync/file_lock.hpp>
#include <openssl/crypto.h>
using namespace std;
using namespace boost;
@ -520,7 +521,7 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
// cost to you of processing a transaction.
if (mapArgs.count("-mintxfee"))
{
int64 n = 0;
int64_t n = 0;
if (ParseMoney(mapArgs["-mintxfee"], n) && n > 0)
CTransaction::nMinTxFee = n;
else
@ -528,7 +529,7 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
}
if (mapArgs.count("-minrelaytxfee"))
{
int64 n = 0;
int64_t n = 0;
if (ParseMoney(mapArgs["-minrelaytxfee"], n) && n > 0)
CTransaction::nMinRelayTxFee = n;
else
@ -582,7 +583,7 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
threadGroup.create_thread(&ThreadScriptCheck);
}
int64 nStart;
int64_t nStart;
// ********************************************************* Step 5: verify wallet database integrity
@ -592,7 +593,7 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
{
// try moving the database env out of the way
boost::filesystem::path pathDatabase = GetDataDir() / "database";
boost::filesystem::path pathDatabaseBak = GetDataDir() / strprintf("database.%"PRI64d".bak", GetTime());
boost::filesystem::path pathDatabaseBak = GetDataDir() / strprintf("database.%"PRId64".bak", GetTime());
try {
boost::filesystem::rename(pathDatabase, pathDatabaseBak);
LogPrintf("Moved old %s to %s. Retrying.\n", pathDatabase.string().c_str(), pathDatabaseBak.string().c_str());
@ -864,7 +865,7 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
LogPrintf("Shutdown requested. Exiting.\n");
return false;
}
LogPrintf(" block index %15"PRI64d"ms\n", GetTimeMillis() - nStart);
LogPrintf(" block index %15"PRId64"ms\n", GetTimeMillis() - nStart);
if (GetBoolArg("-printblockindex", false) || GetBoolArg("-printblocktree", false))
{
@ -957,7 +958,7 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
}
LogPrintf("%s", strErrors.str().c_str());
LogPrintf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart);
LogPrintf(" wallet %15"PRId64"ms\n", GetTimeMillis() - nStart);
RegisterWallet(pwalletMain);
@ -979,7 +980,7 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
LogPrintf("Rescanning last %i blocks (from block %i)...\n", chainActive.Height() - pindexRescan->nHeight, pindexRescan->nHeight);
nStart = GetTimeMillis();
pwalletMain->ScanForWalletTransactions(pindexRescan, true);
LogPrintf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart);
LogPrintf(" rescan %15"PRId64"ms\n", GetTimeMillis() - nStart);
pwalletMain->SetBestChain(chainActive.GetLocator());
nWalletDBUpdated++;
}
@ -1011,7 +1012,7 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
LogPrintf("Invalid or missing peers.dat; recreating\n");
}
LogPrintf("Loaded %i addresses from peers.dat %"PRI64d"ms\n",
LogPrintf("Loaded %i addresses from peers.dat %"PRId64"ms\n",
addrman.size(), GetTimeMillis() - nStart);
// ********************************************************* Step 11: start node

View file

@ -2,14 +2,18 @@
// Copyright (c) 2009-2013 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_INIT_H
#define BITCOIN_INIT_H
#include <string>
#include <boost/thread.hpp>
class CWallet;
namespace boost {
class thread_group;
};
extern std::string strWalletFile;
extern CWallet* pwalletMain;

View file

@ -2,13 +2,12 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <openssl/bn.h>
#include <openssl/ecdsa.h>
#include <openssl/rand.h>
#include <openssl/obj_mac.h>
#include "key.h"
#include <openssl/bn.h>
#include <openssl/ecdsa.h>
#include <openssl/obj_mac.h>
#include <openssl/rand.h>
// anonymous namespace with local implementation code (OpenSSL interaction)
namespace {

View file

@ -2,15 +2,17 @@
// Copyright (c) 2009-2013 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_KEY_H
#define BITCOIN_KEY_H
#include <vector>
#include "allocators.h"
#include "hash.h"
#include "serialize.h"
#include "uint256.h"
#include "hash.h"
#include <stdexcept>
#include <vector>
// secp256k1:
// const unsigned int PRIVATE_KEY_SIZE = 279;

View file

@ -4,8 +4,13 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "keystore.h"
#include "crypter.h"
#include "key.h"
#include "script.h"
#include <boost/foreach.hpp>
bool CKeyStore::GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const
{
CKey key;

View file

@ -2,11 +2,13 @@
// Copyright (c) 2009-2013 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_KEYSTORE_H
#define BITCOIN_KEYSTORE_H
#include "crypter.h"
#include "key.h"
#include "sync.h"
#include <boost/signals2/signal.hpp>
class CScript;
@ -88,8 +90,10 @@ public:
virtual bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const;
};
typedef std::vector<unsigned char, secure_allocator<unsigned char> > CKeyingMaterial;
typedef std::map<CKeyID, std::pair<CPubKey, std::vector<unsigned char> > > CryptedKeyMap;
/** Keystore which keeps the private keys encrypted.
* It derives from the basic key store, which is used if no encryption is active.
*/

View file

@ -3,15 +3,15 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "leveldbwrapper.h"
#include "util.h"
#include <leveldb/env.h>
#include <boost/filesystem.hpp>
#include <leveldb/cache.h>
#include <leveldb/env.h>
#include <leveldb/filter_policy.h>
#include <memenv/memenv.h>
#include <boost/filesystem.hpp>
void HandleError(const leveldb::Status &status) throw(leveldb_error) {
if (status.ok())
return;

View file

@ -7,11 +7,11 @@
#include "serialize.h"
#include "util.h"
#include <leveldb/db.h>
#include <leveldb/write_batch.h>
#include "version.h"
#include <boost/filesystem/path.hpp>
#include <leveldb/db.h>
#include <leveldb/write_batch.h>
class leveldb_error : public std::runtime_error
{

View file

@ -1,12 +1,12 @@
// Copyright (c) 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_LIMITEDMAP_H
#define BITCOIN_LIMITEDMAP_H
#include <assert.h> // TODO: remove
#include <map>
#include <deque>
/** STL-like map container that only keeps the N elements with the highest value. */
template <typename K, typename V> class limitedmap

View file

@ -3,20 +3,26 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include "main.h"
#include "addrman.h"
#include "alert.h"
#include "chainparams.h"
#include "checkpoints.h"
#include "checkqueue.h"
#include "db.h"
#include "init.h"
#include "net.h"
#include "txdb.h"
#include "txmempool.h"
#include "ui_interface.h"
#include "util.h"
#include <inttypes.h>
#include <stdint.h>
#include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
using namespace std;
using namespace boost;
@ -25,16 +31,13 @@ using namespace boost;
// Global state
//
CCriticalSection cs_setpwalletRegistered;
set<CWallet*> setpwalletRegistered;
CCriticalSection cs_main;
CTxMemPool mempool;
map<uint256, CBlockIndex*> mapBlockIndex;
CChain chainActive;
int64 nTimeBestReceived = 0;
int64_t nTimeBestReceived = 0;
int nScriptCheckThreads = 0;
bool fImporting = false;
bool fReindex = false;
@ -43,9 +46,9 @@ bool fTxIndex = false;
unsigned int nCoinCacheSize = 5000;
/** Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) */
int64 CTransaction::nMinTxFee = 10000; // Override with -mintxfee
int64_t CTransaction::nMinTxFee = 10000; // Override with -mintxfee
/** Fees smaller than this (in satoshi) are considered zero fee (for relaying) */
int64 CTransaction::nMinRelayTxFee = 10000;
int64_t CTransaction::nMinRelayTxFee = 10000;
static CMedianFilter<int> cPeerBlockCounts(8, 0); // Amount of blocks that other nodes claim to have
@ -61,7 +64,7 @@ CScript COINBASE_FLAGS;
const string strMessageMagic = "Bitcoin Signed Message:\n";
// Settings
int64 nTransactionFee = 0;
int64_t nTransactionFee = 0;
// Internal stuff
namespace {
@ -481,7 +484,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason)
return true;
}
bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64 nBlockTime)
bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
{
// Time based nLockTime implemented in 0.1.6
if (tx.nLockTime == 0)
@ -490,7 +493,7 @@ bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64 nBlockTime)
nBlockHeight = chainActive.Height();
if (nBlockTime == 0)
nBlockTime = GetAdjustedTime();
if ((int64)tx.nLockTime < ((int64)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64)nBlockHeight : nBlockTime))
if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime))
return true;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
if (!txin.IsFinal())
@ -501,9 +504,9 @@ bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64 nBlockTime)
/** Amount of bitcoins spent by the transaction.
@return sum of all outputs (note: does not include fees)
*/
int64 GetValueOut(const CTransaction& tx)
int64_t GetValueOut(const CTransaction& tx)
{
int64 nValueOut = 0;
int64_t nValueOut = 0;
BOOST_FOREACH(const CTxOut& txout, tx.vout)
{
nValueOut += txout.nValue;
@ -672,7 +675,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
return state.DoS(100, error("CTransaction::CheckTransaction() : size limits failed"));
// Check for negative or overflow output values
int64 nValueOut = 0;
int64_t nValueOut = 0;
BOOST_FOREACH(const CTxOut& txout, tx.vout)
{
if (txout.nValue < 0)
@ -708,13 +711,13 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
return true;
}
int64 GetMinFee(const CTransaction& tx, bool fAllowFree, enum GetMinFee_mode mode)
int64_t GetMinFee(const CTransaction& tx, bool fAllowFree, enum GetMinFee_mode mode)
{
// Base fee is either nMinTxFee or nMinRelayTxFee
int64 nBaseFee = (mode == GMF_RELAY) ? tx.nMinRelayTxFee : tx.nMinTxFee;
int64_t nBaseFee = (mode == GMF_RELAY) ? tx.nMinRelayTxFee : tx.nMinTxFee;
unsigned int nBytes = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee;
int64_t nMinFee = (1 + (int64_t)nBytes / 1000) * nBaseFee;
if (fAllowFree)
{
@ -842,13 +845,13 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
// you should add code here to check that the transaction does a
// reasonable number of ECDSA signature verifications.
int64 nFees = view.GetValueIn(tx)-GetValueOut(tx);
int64_t nFees = view.GetValueIn(tx)-GetValueOut(tx);
unsigned int nSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
// Don't accept it if it can't get into a block
int64 txMinFee = GetMinFee(tx, true, GMF_RELAY);
int64_t txMinFee = GetMinFee(tx, true, GMF_RELAY);
if (fLimitFree && nFees < txMinFee)
return error("AcceptToMemoryPool: : not enough fees %s, %"PRI64d" < %"PRI64d,
return error("AcceptToMemoryPool: : not enough fees %s, %"PRId64" < %"PRId64,
hash.ToString().c_str(),
nFees, txMinFee);
@ -859,8 +862,8 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
{
static CCriticalSection csFreeLimiter;
static double dFreeCount;
static int64 nLastTime;
int64 nNow = GetTime();
static int64_t nLastTime;
int64_t nNow = GetTime();
LOCK(csFreeLimiter);
@ -876,7 +879,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
}
if (fRejectInsaneFee && nFees > CTransaction::nMinRelayTxFee * 10000)
return error("AcceptToMemoryPool: : insane fees %s, %"PRI64d" > %"PRI64d,
return error("AcceptToMemoryPool: : insane fees %s, %"PRId64" > %"PRId64,
hash.ToString().c_str(),
nFees, CTransaction::nMinRelayTxFee * 10000);
@ -1090,9 +1093,9 @@ uint256 static GetOrphanRoot(const CBlockHeader* pblock)
return pblock->GetHash();
}
int64 GetBlockValue(int nHeight, int64 nFees)
int64_t GetBlockValue(int nHeight, int64_t nFees)
{
int64 nSubsidy = 50 * COIN;
int64_t nSubsidy = 50 * COIN;
// Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
nSubsidy >>= (nHeight / Params().SubsidyHalvingInterval());
@ -1100,15 +1103,15 @@ int64 GetBlockValue(int nHeight, int64 nFees)
return nSubsidy + nFees;
}
static const int64 nTargetTimespan = 14 * 24 * 60 * 60; // two weeks
static const int64 nTargetSpacing = 10 * 60;
static const int64 nInterval = nTargetTimespan / nTargetSpacing;
static const int64_t nTargetTimespan = 14 * 24 * 60 * 60; // two weeks
static const int64_t nTargetSpacing = 10 * 60;
static const int64_t nInterval = nTargetTimespan / nTargetSpacing;
//
// minimum amount of work that could possibly be required nTime after
// minimum work required was nBase
//
unsigned int ComputeMinWork(unsigned int nBase, int64 nTime)
unsigned int ComputeMinWork(unsigned int nBase, int64_t nTime)
{
const CBigNum &bnLimit = Params().ProofOfWorkLimit();
// Testnet has min-difficulty blocks
@ -1167,8 +1170,8 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
assert(pindexFirst);
// Limit adjustment step
int64 nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime();
LogPrintf(" nActualTimespan = %"PRI64d" before bounds\n", nActualTimespan);
int64_t nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime();
LogPrintf(" nActualTimespan = %"PRId64" before bounds\n", nActualTimespan);
if (nActualTimespan < nTargetTimespan/4)
nActualTimespan = nTargetTimespan/4;
if (nActualTimespan > nTargetTimespan*4)
@ -1185,7 +1188,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
/// debug print
LogPrintf("GetNextWorkRequired RETARGET\n");
LogPrintf("nTargetTimespan = %"PRI64d" nActualTimespan = %"PRI64d"\n", nTargetTimespan, nActualTimespan);
LogPrintf("nTargetTimespan = %"PRId64" nActualTimespan = %"PRId64"\n", nTargetTimespan, nActualTimespan);
LogPrintf("Before: %08x %s\n", pindexLast->nBits, CBigNum().SetCompact(pindexLast->nBits).getuint256().ToString().c_str());
LogPrintf("After: %08x %s\n", bnNew.GetCompact(), bnNew.getuint256().ToString().c_str());
@ -1218,7 +1221,7 @@ bool IsInitialBlockDownload()
{
if (fImporting || fReindex || chainActive.Height() < Checkpoints::GetTotalBlocksEstimate())
return true;
static int64 nLastUpdate;
static int64_t nLastUpdate;
static CBlockIndex* pindexLastBest;
if (chainActive.Tip() != pindexLastBest)
{
@ -1420,12 +1423,12 @@ const CTxOut &CCoinsViewCache::GetOutputFor(const CTxIn& input)
return coins.vout[input.prevout.n];
}
int64 CCoinsViewCache::GetValueIn(const CTransaction& tx)
int64_t CCoinsViewCache::GetValueIn(const CTransaction& tx)
{
if (tx.IsCoinBase())
return 0;
int64 nResult = 0;
int64_t nResult = 0;
for (unsigned int i = 0; i < tx.vin.size(); i++)
nResult += GetOutputFor(tx.vin[i]).nValue;
@ -1496,8 +1499,8 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, CCoinsViewCach
// While checking, GetBestBlock() refers to the parent block.
// This is also true for mempool checks.
int nSpendHeight = inputs.GetBestBlock()->nHeight + 1;
int64 nValueIn = 0;
int64 nFees = 0;
int64_t nValueIn = 0;
int64_t nFees = 0;
for (unsigned int i = 0; i < tx.vin.size(); i++)
{
const COutPoint &prevout = tx.vin[i].prevout;
@ -1520,7 +1523,7 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, CCoinsViewCach
return state.DoS(100, error("CheckInputs() : %s value in < value out", tx.GetHash().ToString().c_str()));
// Tally transaction fees
int64 nTxFee = nValueIn - GetValueOut(tx);
int64_t nTxFee = nValueIn - GetValueOut(tx);
if (nTxFee < 0)
return state.DoS(100, error("CheckInputs() : %s nTxFee < 0", tx.GetHash().ToString().c_str()));
nFees += nTxFee;
@ -1725,7 +1728,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
}
// BIP16 didn't become active until Apr 1 2012
int64 nBIP16SwitchTime = 1333238400;
int64_t nBIP16SwitchTime = 1333238400;
bool fStrictPayToScriptHash = (pindex->nTime >= nBIP16SwitchTime);
unsigned int flags = SCRIPT_VERIFY_NOCACHE |
@ -1735,8 +1738,8 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
CCheckQueueControl<CScriptCheck> control(fScriptChecks && nScriptCheckThreads ? &scriptcheckqueue : NULL);
int64 nStart = GetTimeMicros();
int64 nFees = 0;
int64_t nStart = GetTimeMicros();
int64_t nFees = 0;
int nInputs = 0;
unsigned int nSigOps = 0;
CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size()));
@ -1782,16 +1785,16 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
vPos.push_back(std::make_pair(block.GetTxHash(i), pos));
pos.nTxOffset += ::GetSerializeSize(tx, SER_DISK, CLIENT_VERSION);
}
int64 nTime = GetTimeMicros() - nStart;
int64_t nTime = GetTimeMicros() - nStart;
if (fBenchmark)
LogPrintf("- Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin)\n", (unsigned)block.vtx.size(), 0.001 * nTime, 0.001 * nTime / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * nTime / (nInputs-1));
if (GetValueOut(block.vtx[0]) > GetBlockValue(pindex->nHeight, nFees))
return state.DoS(100, error("ConnectBlock() : coinbase pays too much (actual=%"PRI64d" vs limit=%"PRI64d")", GetValueOut(block.vtx[0]), GetBlockValue(pindex->nHeight, nFees)));
return state.DoS(100, error("ConnectBlock() : coinbase pays too much (actual=%"PRId64" vs limit=%"PRId64")", GetValueOut(block.vtx[0]), GetBlockValue(pindex->nHeight, nFees)));
if (!control.Wait())
return state.DoS(100, false);
int64 nTime2 = GetTimeMicros() - nStart;
int64_t nTime2 = GetTimeMicros() - nStart;
if (fBenchmark)
LogPrintf("- Verify %u txins: %.2fms (%.3fms/txin)\n", nInputs - 1, 0.001 * nTime2, nInputs <= 1 ? 0 : 0.001 * nTime2 / (nInputs-1));
@ -1879,7 +1882,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
CBlock block;
if (!ReadBlockFromDisk(block, pindex))
return state.Abort(_("Failed to read block"));
int64 nStart = GetTimeMicros();
int64_t nStart = GetTimeMicros();
if (!DisconnectBlock(block, state, pindex, view))
return error("SetBestBlock() : DisconnectBlock %s failed", pindex->GetBlockHash().ToString().c_str());
if (fBenchmark)
@ -1899,7 +1902,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
CBlock block;
if (!ReadBlockFromDisk(block, pindex))
return state.Abort(_("Failed to read block"));
int64 nStart = GetTimeMicros();
int64_t nStart = GetTimeMicros();
if (!ConnectBlock(block, state, pindex, view)) {
if (state.IsInvalid()) {
InvalidChainFound(pindexNew);
@ -1916,10 +1919,10 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
}
// Flush changes to global coin state
int64 nStart = GetTimeMicros();
int64_t nStart = GetTimeMicros();
int nModified = view.GetCacheSize();
assert(view.Flush());
int64 nTime = GetTimeMicros() - nStart;
int64_t nTime = GetTimeMicros() - nStart;
if (fBenchmark)
LogPrintf("- Flush %i transactions: %.2fms (%.4fms/tx)\n", nModified, 0.001 * nTime, 0.001 * nTime / nModified);
@ -2056,7 +2059,7 @@ bool AddToBlockIndex(CBlock& block, CValidationState& state, const CDiskBlockPos
}
bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64 nTime, bool fKnown = false)
bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false)
{
bool fUpdatedLast = false;
@ -2309,7 +2312,7 @@ bool CBlockIndex::IsSuperMajority(int minVersion, const CBlockIndex* pstart, uns
return (nFound >= nRequired);
}
int64 CBlockIndex::GetMedianTime() const
int64_t CBlockIndex::GetMedianTime() const
{
const CBlockIndex* pindex = this;
for (int i = 0; i < nMedianTimeSpan/2; i++)
@ -2349,7 +2352,7 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
if (pcheckpoint && pblock->hashPrevBlock != (chainActive.Tip() ? chainActive.Tip()->GetBlockHash() : uint256(0)))
{
// Extra checks to prevent "fill up memory by spamming with bogus blocks"
int64 deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime;
int64_t deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime;
if (deltaTime < 0)
{
return state.DoS(100, error("ProcessBlock() : block with timestamp before last checkpoint"));
@ -2579,9 +2582,9 @@ bool AbortNode(const std::string &strMessage) {
return false;
}
bool CheckDiskSpace(uint64 nAdditionalBytes)
bool CheckDiskSpace(uint64_t nAdditionalBytes)
{
uint64 nFreeBytesAvailable = filesystem::space(GetDataDir()).available;
uint64_t nFreeBytesAvailable = filesystem::space(GetDataDir()).available;
// Check for nMinDiskSpace bytes (currently 50MB)
if (nFreeBytesAvailable < nMinDiskSpace + nAdditionalBytes)
@ -2888,12 +2891,12 @@ void PrintBlockTree()
bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
{
int64 nStart = GetTimeMillis();
int64_t nStart = GetTimeMillis();
int nLoaded = 0;
try {
CBufferedFile blkdat(fileIn, 2*MAX_BLOCK_SIZE, MAX_BLOCK_SIZE+8, SER_DISK, CLIENT_VERSION);
uint64 nStartByte = 0;
uint64_t nStartByte = 0;
if (dbp) {
// (try to) skip already indexed part
CBlockFileInfo info;
@ -2902,7 +2905,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
blkdat.Seek(info.nSize);
}
}
uint64 nRewind = blkdat.GetPos();
uint64_t nRewind = blkdat.GetPos();
while (blkdat.good() && !blkdat.eof()) {
boost::this_thread::interruption_point();
@ -2928,7 +2931,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
}
try {
// read block
uint64 nBlockPos = blkdat.GetPos();
uint64_t nBlockPos = blkdat.GetPos();
blkdat.SetLimit(nBlockPos + nSize);
CBlock block;
blkdat >> block;
@ -2954,7 +2957,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
AbortNode(_("Error: system error: ") + e.what());
}
if (nLoaded > 0)
LogPrintf("Loaded %i blocks from external file in %"PRI64d"ms\n", nLoaded, GetTimeMillis() - nStart);
LogPrintf("Loaded %i blocks from external file in %"PRId64"ms\n", nLoaded, GetTimeMillis() - nStart);
return nLoaded > 0;
}
@ -2972,9 +2975,6 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
// CAlert
//
extern map<uint256, CAlert> mapAlerts;
extern CCriticalSection cs_mapAlerts;
string GetWarnings(string strFor)
{
int nPriority = 0;
@ -3197,10 +3197,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
return false;
}
int64 nTime;
int64_t nTime;
CAddress addrMe;
CAddress addrFrom;
uint64 nNonce = 1;
uint64_t nNonce = 1;
vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe;
if (pfrom->nVersion < MIN_PEER_PROTO_VERSION)
{
@ -3321,8 +3321,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
// Store the new addresses
vector<CAddress> vAddrOk;
int64 nNow = GetAdjustedTime();
int64 nSince = nNow - 10 * 60;
int64_t nNow = GetAdjustedTime();
int64_t nSince = nNow - 10 * 60;
BOOST_FOREACH(CAddress& addr, vAddr)
{
boost::this_thread::interruption_point();
@ -3341,7 +3341,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
static uint256 hashSalt;
if (hashSalt == 0)
hashSalt = GetRandHash();
uint64 hashAddr = addr.GetHash();
uint64_t hashAddr = addr.GetHash();
uint256 hashRand = hashSalt ^ (hashAddr<<32) ^ ((GetTime()+hashAddr)/(24*60*60));
hashRand = Hash(BEGIN(hashRand), END(hashRand));
multimap<uint256, CNode*> mapMix;
@ -3655,7 +3655,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
{
if (pfrom->nVersion > BIP0031_VERSION)
{
uint64 nonce = 0;
uint64_t nonce = 0;
vRecv >> nonce;
// Echo the message back with the nonce. This allows for two useful features:
//
@ -3675,8 +3675,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
else if (strCommand == "pong")
{
int64 pingUsecEnd = GetTimeMicros();
uint64 nonce = 0;
int64_t pingUsecEnd = GetTimeMicros();
uint64_t nonce = 0;
size_t nAvail = vRecv.in_avail();
bool bPingFinished = false;
std::string sProblem;
@ -3689,7 +3689,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
if (nonce == pfrom->nPingNonceSent) {
// Matching pong received, this ping is no longer outstanding
bPingFinished = true;
int64 pingUsecTime = pingUsecEnd - pfrom->nPingUsecStart;
int64_t pingUsecTime = pingUsecEnd - pfrom->nPingUsecStart;
if (pingUsecTime > 0) {
// Successful ping time measurement, replace previous
pfrom->nPingUsecTime = pingUsecTime;
@ -3716,7 +3716,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
}
if (!(sProblem.empty())) {
LogPrint("net", "pong %s %s: %s, %"PRI64x" expected, %"PRI64x" received, %"PRIszu" bytes\n",
LogPrint("net", "pong %s %s: %s, %"PRIx64" expected, %"PRIx64" received, %"PRIszu" bytes\n",
pfrom->addr.ToString().c_str(),
pfrom->strSubVer.c_str(),
sProblem.c_str(),
@ -3965,7 +3965,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
pingSend = true;
}
if (pingSend) {
uint64 nonce = 0;
uint64_t nonce = 0;
while (nonce == 0) {
RAND_bytes((unsigned char*)&nonce, sizeof(nonce));
}
@ -3983,7 +3983,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
}
// Address refresh broadcast
static int64 nLastRebroadcast;
static int64_t nLastRebroadcast;
if (!IsInitialBlockDownload() && (GetTime() - nLastRebroadcast > 24 * 60 * 60))
{
{
@ -4103,7 +4103,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
// Message: getdata
//
vector<CInv> vGetData;
int64 nNow = GetTime() * 1000000;
int64_t nNow = GetTime() * 1000000;
while (!pto->mapAskFor.empty() && (*pto->mapAskFor.begin()).first <= nNow)
{
const CInv& inv = (*pto->mapAskFor.begin()).second;

View file

@ -2,6 +2,7 @@
// Copyright (c) 2009-2013 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_MAIN_H
#define BITCOIN_MAIN_H
@ -9,22 +10,27 @@
#include "bitcoin-config.h"
#endif
#include "core.h"
#include "bignum.h"
#include "sync.h"
#include "txmempool.h"
#include "chainparams.h"
#include "core.h"
#include "net.h"
#include "script.h"
#include "sync.h"
#include "txmempool.h"
#include "uint256.h"
#include <list>
#include <algorithm>
#include <exception>
#include <map>
#include <set>
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>
class CBlock;
class CBlockIndex;
class CBloomFilter;
class CInv;
class CKeyItem;
class CNode;
class CReserveKey;
class CWallet;
/** The maximum allowed size for a serialized block, in bytes (network rule) */
static const unsigned int MAX_BLOCK_SIZE = 1000000;
@ -45,8 +51,8 @@ static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB
/** Fake height value used in CCoins to signify they are only in the memory pool (since 0.8) */
static const unsigned int MEMPOOL_HEIGHT = 0x7FFFFFFF;
/** No amount larger than this (in satoshi) is valid */
static const int64 MAX_MONEY = 21000000 * COIN;
inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
static const int64_t MAX_MONEY = 21000000 * COIN;
inline bool MoneyRange(int64_t nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */
static const int COINBASE_MATURITY = 100;
/** Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp. */
@ -72,10 +78,10 @@ extern CScript COINBASE_FLAGS;
extern CCriticalSection cs_main;
extern CTxMemPool mempool;
extern std::map<uint256, CBlockIndex*> mapBlockIndex;
extern uint64 nLastBlockTx;
extern uint64 nLastBlockSize;
extern uint64_t nLastBlockTx;
extern uint64_t nLastBlockSize;
extern const std::string strMessageMagic;
extern int64 nTimeBestReceived;
extern int64_t nTimeBestReceived;
extern bool fImporting;
extern bool fReindex;
extern bool fBenchmark;
@ -85,17 +91,15 @@ extern unsigned int nCoinCacheSize;
extern bool fHaveGUI;
// Settings
extern int64 nTransactionFee;
extern int64_t nTransactionFee;
// Minimum disk space required - used in CheckDiskSpace()
static const uint64 nMinDiskSpace = 52428800;
static const uint64_t nMinDiskSpace = 52428800;
class CReserveKey;
class CCoinsDB;
class CBlockTreeDB;
struct CDiskBlockPos;
class CCoins;
class CTxUndo;
class CCoinsView;
class CCoinsViewCache;
@ -124,7 +128,7 @@ void PushGetBlocks(CNode* pnode, CBlockIndex* pindexBegin, uint256 hashEnd);
/** Process an incoming block */
bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBlockPos *dbp = NULL);
/** Check whether enough disk space is available for an incoming block */
bool CheckDiskSpace(uint64 nAdditionalBytes = 0);
bool CheckDiskSpace(uint64_t nAdditionalBytes = 0);
/** Open a block file (blk?????.dat) */
FILE* OpenBlockFile(const CDiskBlockPos &pos, bool fReadOnly = false);
/** Open an undo file (rev?????.dat) */
@ -150,7 +154,7 @@ void ThreadScriptCheck();
/** Check whether a block hash satisfies the proof-of-work requirement specified by nBits */
bool CheckProofOfWork(uint256 hash, unsigned int nBits);
/** Calculate the minimum amount of work a received block needs, without knowing its direct parent */
unsigned int ComputeMinWork(unsigned int nBase, int64 nTime);
unsigned int ComputeMinWork(unsigned int nBase, int64_t nTime);
/** Get the number of active peers */
int GetNumBlocksOfPeers();
/** Check whether we are doing an initial block download (synchronizing from disk or network) */
@ -163,7 +167,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, b
bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew);
/** Find the best known block, and make it the tip of the block chain */
bool ConnectBestBlock(CValidationState &state);
int64 GetBlockValue(int nHeight, int64 nFees);
int64_t GetBlockValue(int nHeight, int64_t nFees);
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock);
void UpdateTime(CBlockHeader& block, const CBlockIndex* pindexPrev);
@ -247,7 +251,7 @@ enum GetMinFee_mode
GMF_SEND,
};
int64 GetMinFee(const CTransaction& tx, bool fAllowFree, enum GetMinFee_mode mode);
int64_t GetMinFee(const CTransaction& tx, bool fAllowFree, enum GetMinFee_mode mode);
//
// Check transaction inputs, and make sure any
@ -307,12 +311,12 @@ bool CheckTransaction(const CTransaction& tx, CValidationState& state);
*/
bool IsStandardTx(const CTransaction& tx, std::string& reason);
bool IsFinalTx(const CTransaction &tx, int nBlockHeight = 0, int64 nBlockTime = 0);
bool IsFinalTx(const CTransaction &tx, int nBlockHeight = 0, int64_t nBlockTime = 0);
/** Amount of bitcoins spent by the transaction.
@return sum of all outputs (note: does not include fees)
*/
int64 GetValueOut(const CTransaction& tx);
int64_t GetValueOut(const CTransaction& tx);
/** Undo information for a CBlock */
class CBlockUndo
@ -600,8 +604,8 @@ public:
unsigned int nUndoSize; // number of used bytes in the undo file
unsigned int nHeightFirst; // lowest height of block in file
unsigned int nHeightLast; // highest height of block in file
uint64 nTimeFirst; // earliest time of block in file
uint64 nTimeLast; // latest time of block in file
uint64_t nTimeFirst; // earliest time of block in file
uint64_t nTimeLast; // latest time of block in file
IMPLEMENT_SERIALIZE(
READWRITE(VARINT(nBlocks));
@ -632,7 +636,7 @@ public:
}
// update statistics (does not update nSize)
void AddBlock(unsigned int nHeightIn, uint64 nTimeIn) {
void AddBlock(unsigned int nHeightIn, uint64_t nTimeIn) {
if (nBlocks==0 || nHeightFirst > nHeightIn)
nHeightFirst = nHeightIn;
if (nBlocks==0 || nTimeFirst > nTimeIn)
@ -786,9 +790,9 @@ public:
return *phashBlock;
}
int64 GetBlockTime() const
int64_t GetBlockTime() const
{
return (int64)nTime;
return (int64_t)nTime;
}
CBigNum GetBlockWork() const
@ -807,11 +811,11 @@ public:
enum { nMedianTimeSpan=11 };
int64 GetMedianTimePast() const
int64_t GetMedianTimePast() const
{
int64 pmedian[nMedianTimeSpan];
int64* pbegin = &pmedian[nMedianTimeSpan];
int64* pend = &pmedian[nMedianTimeSpan];
int64_t pmedian[nMedianTimeSpan];
int64_t* pbegin = &pmedian[nMedianTimeSpan];
int64_t* pend = &pmedian[nMedianTimeSpan];
const CBlockIndex* pindex = this;
for (int i = 0; i < nMedianTimeSpan && pindex; i++, pindex = pindex->pprev)
@ -821,7 +825,7 @@ public:
return pbegin[(pend - pbegin)/2];
}
int64 GetMedianTime() const;
int64_t GetMedianTime() const;
/**
* Returns true if there are nRequired or more blocks of minVersion or above
@ -1035,11 +1039,11 @@ struct CCoinsStats
{
int nHeight;
uint256 hashBlock;
uint64 nTransactions;
uint64 nTransactionOutputs;
uint64 nSerializedSize;
uint64_t nTransactions;
uint64_t nTransactionOutputs;
uint64_t nSerializedSize;
uint256 hashSerialized;
int64 nTotalAmount;
int64_t nTotalAmount;
CCoinsStats() : nHeight(0), hashBlock(0), nTransactions(0), nTransactionOutputs(0), nSerializedSize(0), hashSerialized(0), nTotalAmount(0) {}
};
@ -1130,7 +1134,8 @@ public:
@return Sum of value of all inputs (scriptSigs)
@see CTransaction::FetchInputs
*/
int64 GetValueIn(const CTransaction& tx);
int64_t GetValueIn(const CTransaction& tx);
// Check whether all prevouts of the transaction are present in the UTXO set represented by this view
bool HaveInputs(const CTransaction& tx);

View file

@ -4,10 +4,16 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "miner.h"
#include "core.h"
#include "main.h"
#include "net.h"
#include "wallet.h"
#include <stdint.h>
double dHashesPerSec = 0.0;
int64 nHPSTimerStart = 0;
int64_t nHPSTimerStart = 0;
//////////////////////////////////////////////////////////////////////////////
//
@ -110,8 +116,8 @@ public:
};
uint64 nLastBlockTx = 0;
uint64 nLastBlockSize = 0;
uint64_t nLastBlockTx = 0;
uint64_t nLastBlockSize = 0;
// We want to sort transactions by priority and fee, so:
typedef boost::tuple<double, double, CTransaction*> TxPriority;
@ -173,7 +179,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize);
// Collect memory pool transactions into the block
int64 nFees = 0;
int64_t nFees = 0;
{
LOCK2(cs_main, mempool.cs);
CBlockIndex* pindexPrev = chainActive.Tip();
@ -195,7 +201,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
COrphan* porphan = NULL;
double dPriority = 0;
int64 nTotalIn = 0;
int64_t nTotalIn = 0;
bool fMissingInputs = false;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
{
@ -229,7 +235,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
}
const CCoins &coins = view.GetCoins(txin.prevout.hash);
int64 nValueIn = coins.vout[txin.prevout.n].nValue;
int64_t nValueIn = coins.vout[txin.prevout.n].nValue;
nTotalIn += nValueIn;
int nConf = pindexPrev->nHeight - coins.nHeight + 1;
@ -269,8 +275,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
}
// Collect transactions into block
uint64 nBlockSize = 1000;
uint64 nBlockTx = 0;
uint64_t nBlockSize = 1000;
uint64_t nBlockTx = 0;
int nBlockSigOps = 100;
bool fSortedByFee = (nBlockPrioritySize <= 0);
@ -314,7 +320,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
if (!view.HaveInputs(tx))
continue;
int64 nTxFees = view.GetValueIn(tx)-GetValueOut(tx);
int64_t nTxFees = view.GetValueIn(tx)-GetValueOut(tx);
nTxSigOps += GetP2SHSigOpCount(tx, view);
if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS)
@ -363,7 +369,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
nLastBlockTx = nBlockTx;
nLastBlockSize = nBlockSize;
LogPrintf("CreateNewBlock(): total size %"PRI64u"\n", nBlockSize);
LogPrintf("CreateNewBlock(): total size %"PRIu64"\n", nBlockSize);
pblock->vtx[0].vout[0].nValue = GetBlockValue(pindexPrev->nHeight+1, nFees);
pblocktemplate->vTxFees[0] = -nFees;
@ -550,7 +556,7 @@ void static BitcoinMiner(CWallet *pwallet)
//
// Search
//
int64 nStart = GetTime();
int64_t nStart = GetTime();
uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
uint256 hashbuf[2];
uint256& hash = *alignup<16>(hashbuf);
@ -589,7 +595,7 @@ void static BitcoinMiner(CWallet *pwallet)
}
// Meter hashes/sec
static int64 nHashCounter;
static int64_t nHashCounter;
if (nHPSTimerStart == 0)
{
nHPSTimerStart = GetTimeMillis();
@ -607,7 +613,7 @@ void static BitcoinMiner(CWallet *pwallet)
dHashesPerSec = 1000.0 * nHashCounter / (GetTimeMillis() - nHPSTimerStart);
nHPSTimerStart = GetTimeMillis();
nHashCounter = 0;
static int64 nLogTime;
static int64_t nLogTime;
if (GetTime() - nLogTime > 30 * 60)
{
nLogTime = GetTime();

View file

@ -2,11 +2,18 @@
// Copyright (c) 2009-2013 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_MINER_H
#define BITCOIN_MINER_H
#include "core.h"
#include "wallet.h"
#include <stdint.h>
class CBlock;
class CBlockIndex;
class CBlockTemplate;
class CReserveKey;
class CScript;
class CWallet;
/** Run the miner threads */
void GenerateBitcoins(bool fGenerate, CWallet* pwallet);
@ -23,6 +30,6 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey);
void SHA256Transform(void* pstate, void* pinput, const void* pinit);
extern double dHashesPerSec;
extern int64 nHPSTimerStart;
extern int64_t nHPSTimerStart;
#endif // BITCOIN_MINER_H

View file

@ -1,11 +1,13 @@
// Copyright (c) 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_MRUSET_H
#define BITCOIN_MRUSET_H
#include <set>
#include <deque>
#include <set>
#include <utility>
/** STL-like set container that only keeps the most recent N elements. */
template <typename T> class mruset

View file

@ -7,32 +7,34 @@
#include "bitcoin-config.h"
#endif
#include "chainparams.h"
#include "db.h"
#include "net.h"
#include "core.h"
#include "addrman.h"
#include "chainparams.h"
#include "core.h"
#include "db.h"
#include "ui_interface.h"
#include "script.h"
#include <inttypes.h>
#include <stdint.h>
#ifdef WIN32
#include <string.h>
#endif
#ifndef WIN32
#else
#include <fcntl.h>
#endif
#ifdef USE_UPNP
#include <miniupnpc/miniwget.h>
#include <miniupnpc/miniupnpc.h>
#include <miniupnpc/miniwget.h>
#include <miniupnpc/upnpcommands.h>
#include <miniupnpc/upnperrors.h>
#endif
// Dump addresses to peers.dat every 15 minutes (900s)
#define DUMP_ADDRESSES_INTERVAL 900
#if !defined(HAVE_MSG_NOSIGNAL)
#if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
#define MSG_NOSIGNAL 0
#endif
@ -53,14 +55,14 @@ struct LocalServiceInfo {
// Global state variables
//
bool fDiscover = true;
uint64 nLocalServices = NODE_NETWORK;
uint64_t nLocalServices = NODE_NETWORK;
static CCriticalSection cs_mapLocalHost;
static map<CNetAddr, LocalServiceInfo> mapLocalHost;
static bool vfReachable[NET_MAX] = {};
static bool vfLimited[NET_MAX] = {};
static CNode* pnodeLocalHost = NULL;
static CNode* pnodeSync = NULL;
uint64 nLocalHostNonce = 0;
uint64_t nLocalHostNonce = 0;
static std::vector<SOCKET> vhListenSocket;
CAddrMan addrman;
int nMaxConnections = 125;
@ -68,9 +70,9 @@ int nMaxConnections = 125;
vector<CNode*> vNodes;
CCriticalSection cs_vNodes;
map<CInv, CDataStream> mapRelay;
deque<pair<int64, CInv> > vRelayExpiration;
deque<pair<int64_t, CInv> > vRelayExpiration;
CCriticalSection cs_mapRelay;
limitedmap<CInv, int64> mapAlreadyAskedFor(MAX_INV_SZ);
limitedmap<CInv, int64_t> mapAlreadyAskedFor(MAX_INV_SZ);
static deque<string> vOneShots;
CCriticalSection cs_vOneShots;
@ -426,8 +428,8 @@ void AddressCurrentlyConnected(const CService& addr)
uint64 CNode::nTotalBytesRecv = 0;
uint64 CNode::nTotalBytesSent = 0;
uint64_t CNode::nTotalBytesRecv = 0;
uint64_t CNode::nTotalBytesSent = 0;
CCriticalSection CNode::cs_totalBytesRecv;
CCriticalSection CNode::cs_totalBytesSent;
@ -545,7 +547,7 @@ void CNode::PushVersion()
int nBestHeight = g_signals.GetHeight().get_value_or(0);
/// when NTP implemented, change to just nTime = GetAdjustedTime()
int64 nTime = (fInbound ? GetAdjustedTime() : GetTime());
int64_t nTime = (fInbound ? GetAdjustedTime() : GetTime());
CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0",0)));
CAddress addrMe = GetLocalAddress(&addr);
RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
@ -558,7 +560,7 @@ void CNode::PushVersion()
std::map<CNetAddr, int64> CNode::setBanned;
std::map<CNetAddr, int64_t> CNode::setBanned;
CCriticalSection CNode::cs_setBanned;
void CNode::ClearBanned()
@ -571,10 +573,10 @@ bool CNode::IsBanned(CNetAddr ip)
bool fResult = false;
{
LOCK(cs_setBanned);
std::map<CNetAddr, int64>::iterator i = setBanned.find(ip);
std::map<CNetAddr, int64_t>::iterator i = setBanned.find(ip);
if (i != setBanned.end())
{
int64 t = (*i).second;
int64_t t = (*i).second;
if (GetTime() < t)
fResult = true;
}
@ -593,7 +595,7 @@ bool CNode::Misbehaving(int howmuch)
nMisbehavior += howmuch;
if (nMisbehavior >= GetArg("-banscore", 100))
{
int64 banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban
int64_t banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban
LogPrintf("Misbehaving: %s (%d -> %d) DISCONNECTING\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior);
{
LOCK(cs_setBanned);
@ -631,7 +633,7 @@ void CNode::copyStats(CNodeStats &stats)
// since pingtime does not update until the ping is complete, which might take a while.
// So, if a ping is taking an unusually long time in flight,
// the caller can immediately detect that this is happening.
int64 nPingUsecWait = 0;
int64_t nPingUsecWait = 0;
if ((0 != nPingNonceSent) && (0 != nPingUsecStart)) {
nPingUsecWait = GetTimeMicros() - nPingUsecStart;
}
@ -1252,12 +1254,12 @@ void ThreadDNSAddressSeed()
void DumpAddresses()
{
int64 nStart = GetTimeMillis();
int64_t nStart = GetTimeMillis();
CAddrDB adb;
adb.Write(addrman);
LogPrint("net", "Flushed %d addresses to peers.dat %"PRI64d"ms\n",
LogPrint("net", "Flushed %d addresses to peers.dat %"PRId64"ms\n",
addrman.size(), GetTimeMillis() - nStart);
}
@ -1284,7 +1286,7 @@ void ThreadOpenConnections()
// Connect to specific addresses
if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0)
{
for (int64 nLoop = 0;; nLoop++)
for (int64_t nLoop = 0;; nLoop++)
{
ProcessOneShot();
BOOST_FOREACH(string strAddr, mapMultiArgs["-connect"])
@ -1301,7 +1303,7 @@ void ThreadOpenConnections()
}
// Initiate network connections
int64 nStart = GetTime();
int64_t nStart = GetTime();
while (true)
{
ProcessOneShot();
@ -1340,7 +1342,7 @@ void ThreadOpenConnections()
}
}
int64 nANow = GetAdjustedTime();
int64_t nANow = GetAdjustedTime();
int nTries = 0;
while (true)
@ -1885,25 +1887,25 @@ void RelayTransaction(const CTransaction& tx, const uint256& hash, const CDataSt
}
}
void CNode::RecordBytesRecv(uint64 bytes)
void CNode::RecordBytesRecv(uint64_t bytes)
{
LOCK(cs_totalBytesRecv);
nTotalBytesRecv += bytes;
}
void CNode::RecordBytesSent(uint64 bytes)
void CNode::RecordBytesSent(uint64_t bytes)
{
LOCK(cs_totalBytesSent);
nTotalBytesSent += bytes;
}
uint64 CNode::GetTotalBytesRecv()
uint64_t CNode::GetTotalBytesRecv()
{
LOCK(cs_totalBytesRecv);
return nTotalBytesRecv;
}
uint64 CNode::GetTotalBytesSent()
uint64_t CNode::GetTotalBytesSent()
{
LOCK(cs_totalBytesSent);
return nTotalBytesSent;

109
src/net.h
View file

@ -2,35 +2,46 @@
// Copyright (c) 2009-2013 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_NET_H
#define BITCOIN_NET_H
#include "bloom.h"
#include "compat.h"
#include "hash.h"
#include "limitedmap.h"
#include "mruset.h"
#include "netbase.h"
#include "protocol.h"
#include "sync.h"
#include "uint256.h"
#include "util.h"
#include <deque>
#include <boost/array.hpp>
#include <boost/foreach.hpp>
#include <boost/signals2/signal.hpp>
#include <openssl/rand.h>
#include <inttypes.h>
#include <stdint.h>
#ifndef WIN32
#include <arpa/inet.h>
#endif
#include "mruset.h"
#include "limitedmap.h"
#include "netbase.h"
#include "protocol.h"
#include "addrman.h"
#include "hash.h"
#include "bloom.h"
//#include <boost/array.hpp>
#include <boost/foreach.hpp>
#include <boost/signals2/signal.hpp>
#include <openssl/rand.h>
class CAddrMan;
class CBlockIndex;
class CNetAddr;
class CNode;
namespace boost {
class thread_group;
}
/** The maximum number of entries in an 'inv' protocol message */
static const unsigned int MAX_INV_SZ = 50000;
class CNode;
class CBlockIndex;
inline unsigned int ReceiveFloodSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); }
inline unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 1*1000); }
@ -85,17 +96,17 @@ CAddress GetLocalAddress(const CNetAddr *paddrPeer = NULL);
extern bool fDiscover;
extern uint64 nLocalServices;
extern uint64 nLocalHostNonce;
extern uint64_t nLocalServices;
extern uint64_t nLocalHostNonce;
extern CAddrMan addrman;
extern int nMaxConnections;
extern std::vector<CNode*> vNodes;
extern CCriticalSection cs_vNodes;
extern std::map<CInv, CDataStream> mapRelay;
extern std::deque<std::pair<int64, CInv> > vRelayExpiration;
extern std::deque<std::pair<int64_t, CInv> > vRelayExpiration;
extern CCriticalSection cs_mapRelay;
extern limitedmap<CInv, int64> mapAlreadyAskedFor;
extern limitedmap<CInv, int64_t> mapAlreadyAskedFor;
extern std::vector<std::string> vAddedNodes;
extern CCriticalSection cs_vAddedNodes;
@ -106,18 +117,18 @@ extern CCriticalSection cs_vAddedNodes;
class CNodeStats
{
public:
uint64 nServices;
int64 nLastSend;
int64 nLastRecv;
int64 nTimeConnected;
uint64_t nServices;
int64_t nLastSend;
int64_t nLastRecv;
int64_t nTimeConnected;
std::string addrName;
int nVersion;
std::string strSubVer;
bool fInbound;
int nStartingHeight;
int nMisbehavior;
uint64 nSendBytes;
uint64 nRecvBytes;
uint64_t nSendBytes;
uint64_t nRecvBytes;
bool fSyncNode;
double dPingTime;
double dPingWait;
@ -171,25 +182,25 @@ class CNode
{
public:
// socket
uint64 nServices;
uint64_t nServices;
SOCKET hSocket;
CDataStream ssSend;
size_t nSendSize; // total size of all vSendMsg entries
size_t nSendOffset; // offset inside the first vSendMsg already sent
uint64 nSendBytes;
uint64_t nSendBytes;
std::deque<CSerializeData> vSendMsg;
CCriticalSection cs_vSend;
std::deque<CInv> vRecvGetData;
std::deque<CNetMessage> vRecvMsg;
CCriticalSection cs_vRecvMsg;
uint64 nRecvBytes;
uint64_t nRecvBytes;
int nRecvVersion;
int64 nLastSend;
int64 nLastRecv;
int64 nLastSendEmpty;
int64 nTimeConnected;
int64_t nLastSend;
int64_t nLastRecv;
int64_t nLastSendEmpty;
int64_t nTimeConnected;
CAddress addr;
std::string addrName;
CService addrLocal;
@ -214,7 +225,7 @@ protected:
// Denial-of-service detection/prevention
// Key is IP address, value is banned-until-time
static std::map<CNetAddr, int64> setBanned;
static std::map<CNetAddr, int64_t> setBanned;
static CCriticalSection cs_setBanned;
int nMisbehavior;
@ -238,12 +249,12 @@ public:
mruset<CInv> setInventoryKnown;
std::vector<CInv> vInventoryToSend;
CCriticalSection cs_inventory;
std::multimap<int64, CInv> mapAskFor;
std::multimap<int64_t, CInv> mapAskFor;
// Ping time measurement
uint64 nPingNonceSent;
int64 nPingUsecStart;
int64 nPingUsecTime;
uint64_t nPingNonceSent;
int64_t nPingUsecStart;
int64_t nPingUsecTime;
bool fPingQueued;
CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn = "", bool fInboundIn=false) : ssSend(SER_NETWORK, INIT_PROTO_VERSION)
@ -305,8 +316,8 @@ private:
// Network usage totals
static CCriticalSection cs_totalBytesRecv;
static CCriticalSection cs_totalBytesSent;
static uint64 nTotalBytesRecv;
static uint64 nTotalBytesSent;
static uint64_t nTotalBytesRecv;
static uint64_t nTotalBytesSent;
CNode(const CNode&);
void operator=(const CNode&);
@ -389,17 +400,17 @@ public:
{
// We're using mapAskFor as a priority queue,
// the key is the earliest time the request can be sent
int64 nRequestTime;
limitedmap<CInv, int64>::const_iterator it = mapAlreadyAskedFor.find(inv);
int64_t nRequestTime;
limitedmap<CInv, int64_t>::const_iterator it = mapAlreadyAskedFor.find(inv);
if (it != mapAlreadyAskedFor.end())
nRequestTime = it->second;
else
nRequestTime = 0;
LogPrint("net", "askfor %s %"PRI64d" (%s)\n", inv.ToString().c_str(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str());
LogPrint("net", "askfor %s %"PRId64" (%s)\n", inv.ToString().c_str(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str());
// Make sure not to reuse time indexes to keep things in the same order
int64 nNow = (GetTime() - 1) * 1000000;
static int64 nLastTime;
int64_t nNow = (GetTime() - 1) * 1000000;
static int64_t nLastTime;
++nLastTime;
nNow = std::max(nNow, nLastTime);
nLastTime = nNow;
@ -664,11 +675,11 @@ public:
void copyStats(CNodeStats &stats);
// Network stats
static void RecordBytesRecv(uint64 bytes);
static void RecordBytesSent(uint64 bytes);
static void RecordBytesRecv(uint64_t bytes);
static void RecordBytesSent(uint64_t bytes);
static uint64 GetTotalBytesRecv();
static uint64 GetTotalBytesSent();
static uint64_t GetTotalBytesRecv();
static uint64_t GetTotalBytesSent();
};

View file

@ -4,9 +4,13 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "netbase.h"
#include "util.h"
#include "sync.h"
#include "hash.h"
#include "sync.h"
#include "uint256.h"
#include "util.h"
#include <stdint.h>
#ifndef WIN32
#include <fcntl.h>
@ -15,7 +19,7 @@
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
#include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith()
#if !defined(HAVE_MSG_NOSIGNAL)
#if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
#define MSG_NOSIGNAL 0
#endif
@ -883,10 +887,10 @@ std::vector<unsigned char> CNetAddr::GetGroup() const
return vchRet;
}
uint64 CNetAddr::GetHash() const
uint64_t CNetAddr::GetHash() const
{
uint256 hash = Hash(&ip[0], &ip[16]);
uint64 nRet;
uint64_t nRet;
memcpy(&nRet, &hash, sizeof(nRet));
return nRet;
}

View file

@ -1,6 +1,7 @@
// Copyright (c) 2009-2013 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_NETBASE_H
#define BITCOIN_NETBASE_H
@ -8,12 +9,13 @@
#include "bitcoin-config.h"
#endif
#include "compat.h"
#include "serialize.h"
#include <stdint.h>
#include <string>
#include <vector>
#include "serialize.h"
#include "compat.h"
extern int nConnectTimeout;
#ifdef WIN32
@ -69,7 +71,7 @@ class CNetAddr
std::string ToString() const;
std::string ToStringIP() const;
unsigned int GetByte(int n) const;
uint64 GetHash() const;
uint64_t GetHash() const;
bool GetInAddr(struct in_addr* pipv4Addr) const;
std::vector<unsigned char> GetGroup() const;
int GetReachabilityFrom(const CNetAddr *paddrPartner = NULL) const;

View file

@ -3,10 +3,12 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "ui_interface.h"
#include "init.h"
#include "bitcoinrpc.h"
#include "noui.h"
#include "ui_interface.h"
#include "util.h"
#include <stdint.h>
#include <string>
static bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
@ -32,7 +34,7 @@ static bool noui_ThreadSafeMessageBox(const std::string& message, const std::str
return false;
}
static bool noui_ThreadSafeAskFee(int64 /*nFeeRequired*/)
static bool noui_ThreadSafeAskFee(int64_t /*nFeeRequired*/)
{
return true;
}

10
src/noui.h Normal file
View file

@ -0,0 +1,10 @@
// Copyright (c) 2013 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_NOUI_H
#define BITCOIN_NOUI_H
extern void noui_connect();
#endif

View file

@ -4,8 +4,10 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "protocol.h"
#include "util.h"
#include "netbase.h"
#include <stdint.h>
#ifndef WIN32
# include <arpa/inet.h>
@ -81,7 +83,7 @@ CAddress::CAddress() : CService()
Init();
}
CAddress::CAddress(CService ipIn, uint64 nServicesIn) : CService(ipIn)
CAddress::CAddress(CService ipIn, uint64_t nServicesIn) : CService(ipIn)
{
Init();
nServices = nServicesIn;

View file

@ -11,11 +11,13 @@
#define __INCLUDED_PROTOCOL_H__
#include "chainparams.h"
#include "serialize.h"
#include "netbase.h"
#include <string>
#include "serialize.h"
#include "uint256.h"
#include <stdint.h>
#include <string>
/** Message header.
* (4) message start.
* (12) command.
@ -67,7 +69,7 @@ class CAddress : public CService
{
public:
CAddress();
explicit CAddress(CService ipIn, uint64 nServicesIn=NODE_NETWORK);
explicit CAddress(CService ipIn, uint64_t nServicesIn=NODE_NETWORK);
void Init();
@ -90,13 +92,13 @@ class CAddress : public CService
// TODO: make private (improves encapsulation)
public:
uint64 nServices;
uint64_t nServices;
// disk and network only
unsigned int nTime;
// memory only
int64 nLastTry;
int64_t nLastTry;
};
/** inv message data */

View file

@ -6,6 +6,7 @@
#include "ui_aboutdialog.h"
#include "clientmodel.h"
#include "clientversion.h"
AboutDialog::AboutDialog(QWidget *parent) :

View file

@ -7,10 +7,11 @@
#include <QDialog>
class ClientModel;
namespace Ui {
class AboutDialog;
}
class ClientModel;
/** "About" dialog box */
class AboutDialog : public QDialog

View file

@ -11,14 +11,14 @@
#include "addresstablemodel.h"
#include "bitcoingui.h"
#include "editaddressdialog.h"
#include "csvmodelwriter.h"
#include "editaddressdialog.h"
#include "guiutil.h"
#include <QSortFilterProxyModel>
#include <QClipboard>
#include <QMessageBox>
#include <QIcon>
#include <QMenu>
#include <QMessageBox>
#include <QSortFilterProxyModel>
AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
QDialog(parent),

View file

@ -7,17 +7,19 @@
#include <QDialog>
class AddressTableModel;
class OptionsModel;
namespace Ui {
class AddressBookPage;
}
class AddressTableModel;
QT_BEGIN_NAMESPACE
class QTableView;
class QItemSelection;
class QSortFilterProxyModel;
class QMenu;
class QModelIndex;
class QSortFilterProxyModel;
class QTableView;
QT_END_NAMESPACE
/** Widget that shows a list of sending or receiving addresses.

View file

@ -7,8 +7,8 @@
#include "guiutil.h"
#include "walletmodel.h"
#include "wallet.h"
#include "base58.h"
#include "wallet.h"
#include <QFont>
#include <QDebug>

View file

@ -9,9 +9,10 @@
#include <QStringList>
class AddressTablePriv;
class CWallet;
class WalletModel;
class CWallet;
/**
Qt model of the address book in the core. This allows views to access and modify the address book.
*/

View file

@ -8,9 +8,11 @@
#include "guiconstants.h"
#include "walletmodel.h"
#include "allocators.h"
#include <QKeyEvent>
#include <QMessageBox>
#include <QPushButton>
#include <QKeyEvent>
AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) :
QDialog(parent),

View file

@ -7,10 +7,11 @@
#include <QDialog>
class WalletModel;
namespace Ui {
class AskPassphraseDialog;
}
class WalletModel;
/** Multifunctional dialog to ask for passphrases. Used for encryption, unlocking, and changing the passphrase.
*/

View file

@ -3,28 +3,35 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "bitcoingui.h"
#include "clientmodel.h"
#include "walletmodel.h"
#include "optionsmodel.h"
#include "guiutil.h"
#include "guiconstants.h"
#include "init.h"
#include "util.h"
#include "ui_interface.h"
#include "guiutil.h"
#include "intro.h"
#include "optionsmodel.h"
#include "paymentserver.h"
#include "splashscreen.h"
#include "intro.h"
#include "walletmodel.h"
#include "init.h"
#include "main.h"
#include "ui_interface.h"
#include "util.h"
#include <stdint.h>
#include <boost/filesystem/operations.hpp>
#include <QApplication>
#include <QLibraryInfo>
#include <QLocale>
#include <QMessageBox>
#include <QSettings>
#include <QTimer>
#include <QTranslator>
#if QT_VERSION < 0x050000
#include <QTextCodec>
#endif
#include <QLocale>
#include <QTimer>
#include <QTranslator>
#include <QLibraryInfo>
#include <QSettings>
#if defined(BITCOIN_NEED_QT_PLUGINS) && !defined(_BITCOIN_QT_PLUGINS_INCLUDED)
#define _BITCOIN_QT_PLUGINS_INCLUDED
@ -68,7 +75,7 @@ static bool ThreadSafeMessageBox(const std::string& message, const std::string&
}
}
static bool ThreadSafeAskFee(int64 nFeeRequired)
static bool ThreadSafeAskFee(int64_t nFeeRequired)
{
if(!guiref)
return false;

View file

@ -4,15 +4,14 @@
#include "bitcoinamountfield.h"
#include "qvaluecombobox.h"
#include "bitcoinunits.h"
#include "guiconstants.h"
#include "qvaluecombobox.h"
#include <QApplication>
#include <QDoubleSpinBox>
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QDoubleSpinBox>
#include <qmath.h> // for qPow()
BitcoinAmountField::BitcoinAmountField(QWidget *parent):

View file

@ -4,49 +4,54 @@
#include "bitcoingui.h"
#include "optionsdialog.h"
#include "aboutdialog.h"
#include "clientmodel.h"
#include "walletmodel.h"
#include "walletframe.h"
#include "optionsmodel.h"
#include "bitcoinunits.h"
#include "clientmodel.h"
#include "guiconstants.h"
#include "notificator.h"
#include "guiutil.h"
#include "notificator.h"
#include "optionsdialog.h"
#include "optionsmodel.h"
#include "rpcconsole.h"
#include "ui_interface.h"
#include "wallet.h"
#include "init.h"
#include "walletframe.h"
#include "walletmodel.h"
#ifdef Q_OS_MAC
#include "macdockiconhandler.h"
#endif
#include "init.h"
#include "ui_interface.h"
#include <iostream>
#include <QApplication>
#include <QMenuBar>
#include <QMenu>
#include <QIcon>
#include <QVBoxLayout>
#include <QToolBar>
#include <QStatusBar>
#include <QLabel>
#include <QMessageBox>
#include <QProgressBar>
#include <QStackedWidget>
#include <QDateTime>
#include <QMovie>
#include <QTimer>
#include <QDesktopWidget>
#include <QDragEnterEvent>
#include <QIcon>
#include <QLabel>
#include <QListWidget>
#include <QMenu>
#include <QMenuBar>
#include <QMessageBox>
#include <QMimeData>
#include <QMovie>
#include <QProgressBar>
#include <QSettings>
#include <QStackedWidget>
#include <QStatusBar>
#include <QStyle>
#include <QTimer>
#include <QToolBar>
#include <QVBoxLayout>
#if QT_VERSION < 0x050000
#include <QUrl>
#include <QTextDocument>
#else
#include <QUrlQuery>
#endif
#include <QMimeData>
#include <QStyle>
#include <QListWidget>
#include <iostream>
const QString BitcoinGUI::DEFAULT_WALLET = "~Default";

View file

@ -6,32 +6,22 @@
#define BITCOINGUI_H
#include <QMainWindow>
#include <QSystemTrayIcon>
#include <QMap>
#include <QSystemTrayIcon>
class WalletFrame;
class WalletView;
class ClientModel;
class WalletModel;
class WalletStack;
class OverviewPage;
class SendCoinsDialog;
class SendCoinsRecipient;
class SignVerifyMessageDialog;
class Notificator;
class RPCConsole;
class SendCoinsRecipient;
class WalletFrame;
class WalletModel;
class CWallet;
QT_BEGIN_NAMESPACE
class QLabel;
class QModelIndex;
class QProgressBar;
class QStackedWidget;
class QUrl;
class QListWidget;
class QPushButton;
class QAction;
class QLabel;
class QProgressBar;
QT_END_NAMESPACE
/**

View file

@ -1,4 +1,7 @@
#include <QtGlobal>
// Automatically generated by extract_strings.py
#ifdef __GNUC__
#define UNUSED __attribute__((unused))
@ -221,4 +224,4 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Warning"),
QT_TRANSLATE_NOOP("bitcoin-core", "Warning: This version is obsolete, upgrade required!"),
QT_TRANSLATE_NOOP("bitcoin-core", "You need to rebuild the database using -reindex to change -txindex"),
QT_TRANSLATE_NOOP("bitcoin-core", "wallet.dat corrupt, salvage failed"),
};
};

View file

@ -5,8 +5,8 @@
#ifndef BITCOINUNITS_H
#define BITCOINUNITS_H
#include <QString>
#include <QAbstractListModel>
#include <QString>
/** Bitcoin unit definitions. Encapsulates parsing and formatting
and serves as list model for drop-down selection boxes.

View file

@ -5,21 +5,21 @@
#include "clientmodel.h"
#include "guiconstants.h"
#include "optionsmodel.h"
#include "addresstablemodel.h"
#include "transactiontablemodel.h"
#include "chainparams.h"
#include "alert.h"
#include "main.h"
#include "chainparams.h"
#include "checkpoints.h"
#include "main.h"
#include "net.h"
#include "ui_interface.h"
#include <QDateTime>
#include <QTimer>
#include <QDebug>
#include <stdint.h>
static const int64 nClientStartupTime = GetTime();
#include <QDateTime>
#include <QDebug>
#include <QTimer>
static const int64_t nClientStartupTime = GetTime();
ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) :
QObject(parent), optionsModel(optionsModel),

View file

@ -7,9 +7,10 @@
#include <QObject>
class OptionsModel;
class AddressTableModel;
class OptionsModel;
class TransactionTableModel;
class CWallet;
QT_BEGIN_NAMESPACE

View file

@ -5,8 +5,8 @@
#ifndef CSVMODELWRITER_H
#define CSVMODELWRITER_H
#include <QObject>
#include <QList>
#include <QObject>
QT_BEGIN_NAMESPACE
class QAbstractItemModel;

View file

@ -7,10 +7,11 @@
#include <QDialog>
class AddressTableModel;
namespace Ui {
class EditAddressDialog;
}
class AddressTableModel;
QT_BEGIN_NAMESPACE
class QDataWidgetMapper;

View file

@ -5,33 +5,12 @@
#include "guiutil.h"
#include "bitcoinaddressvalidator.h"
#include "walletmodel.h"
#include "bitcoinunits.h"
#include "walletmodel.h"
#include "util.h"
#include "core.h"
#include "init.h"
#include <QApplication>
#include <QDateTime>
#include <QDoubleValidator>
#include <QFont>
#include <QLineEdit>
#if QT_VERSION >= 0x050000
#include <QUrlQuery>
#else
#include <QUrl>
#endif
#include <QTextDocument> // for Qt::mightBeRichText
#include <QAbstractItemView>
#include <QClipboard>
#include <QFileDialog>
#include <QDesktopServices>
#include <QThread>
#include <QSettings>
#include <QDesktopWidget>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include "util.h"
#ifdef WIN32
#ifdef _WIN32_WINNT
@ -46,9 +25,31 @@
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include "shlwapi.h"
#include "shlobj.h"
#include "shellapi.h"
#include "shlobj.h"
#include "shlwapi.h"
#endif
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <QAbstractItemView>
#include <QApplication>
#include <QClipboard>
#include <QDateTime>
#include <QDesktopServices>
#include <QDesktopWidget>
#include <QDoubleValidator>
#include <QFileDialog>
#include <QFont>
#include <QLineEdit>
#include <QSettings>
#include <QTextDocument> // for Qt::mightBeRichText
#include <QThread>
#if QT_VERSION < 0x050000
#include <QUrl>
#else
#include <QUrlQuery>
#endif
namespace GUIUtil {

View file

@ -5,19 +5,19 @@
#ifndef GUIUTIL_H
#define GUIUTIL_H
#include <QString>
#include <QObject>
#include <QMessageBox>
#include <QObject>
#include <QString>
class SendCoinsRecipient;
QT_BEGIN_NAMESPACE
class QAbstractItemView;
class QDateTime;
class QFont;
class QLineEdit;
class QWidget;
class QDateTime;
class QUrl;
class QAbstractItemView;
class QWidget;
QT_END_NAMESPACE
/** Utility functions used by the Bitcoin Qt UI.

View file

@ -4,17 +4,17 @@
#include "intro.h"
#include "ui_intro.h"
#include "util.h"
#include <boost/filesystem.hpp>
#include <QFileDialog>
#include <QSettings>
#include <QMessageBox>
#include <boost/filesystem.hpp>
/* Minimum free space (in bytes) needed for data directory */
static const uint64 GB_BYTES = 1000000000LL;
static const uint64 BLOCK_CHAIN_SIZE = 10LL * GB_BYTES;
static const uint64_t GB_BYTES = 1000000000LL;
static const uint64_t BLOCK_CHAIN_SIZE = 10LL * GB_BYTES;
/* Check free space asynchronously to prevent hanging the UI thread.
@ -60,7 +60,7 @@ void FreespaceChecker::check()
namespace fs = boost::filesystem;
QString dataDirStr = intro->getPathToCheck();
fs::path dataDir = fs::path(dataDirStr.toStdString());
uint64 freeBytesAvailable = 0;
uint64_t freeBytesAvailable = 0;
int replyStatus = ST_OK;
QString replyMessage = tr("A new data directory will be created.");

View file

@ -6,13 +6,14 @@
#define INTRO_H
#include <QDialog>
#include <QThread>
#include <QMutex>
#include <QThread>
class FreespaceChecker;
namespace Ui {
class Intro;
}
class FreespaceChecker;
/** Introduction screen (pre-GUI startup).
Allows the user to choose a data directory,

View file

@ -5,12 +5,12 @@
#ifndef MACDOCKICONHANDLER_H
#define MACDOCKICONHANDLER_H
#include <QObject>
#include <QMainWindow>
#include <QObject>
QT_BEGIN_NAMESPACE
class QMenu;
class QIcon;
class QMenu;
class QWidget;
QT_END_NAMESPACE

View file

@ -4,6 +4,7 @@
#ifndef MACNOTIFICATIONHANDLER_H
#define MACNOTIFICATIONHANDLER_H
#include <QObject>
/** Macintosh-specific notification handler (supports UserNotificationCenter and Growl).

View file

@ -4,9 +4,9 @@
#include "monitoreddatamapper.h"
#include <QWidget>
#include <QMetaObject>
#include <QMetaProperty>
#include <QWidget>
MonitoredDataMapper::MonitoredDataMapper(QObject *parent) :
QDataWidgetMapper(parent)

View file

@ -4,27 +4,31 @@
#include "notificator.h"
#include <QApplication>
#include <QMetaType>
#include <QVariant>
#include <QIcon>
#include <QStyle>
#include <QByteArray>
#include <QSystemTrayIcon>
#include <QMessageBox>
#include <QTemporaryFile>
#include <QImageWriter>
#ifdef USE_DBUS
#include <QtDBus>
#include <stdint.h>
#endif
#include <QApplication>
#include <QByteArray>
#include <QIcon>
#include <QImageWriter>
#include <QMessageBox>
#include <QMetaType>
#include <QStyle>
#include <QSystemTrayIcon>
#include <QTemporaryFile>
#include <QVariant>
#ifdef Q_OS_MAC
#include <ApplicationServices/ApplicationServices.h>
#include "macnotificationhandler.h"
#include <ApplicationServices/ApplicationServices.h>
#endif
#ifdef USE_DBUS
#include <stdint.h>
#include <QtDBus>
#endif
// https://wiki.ubuntu.com/NotificationDevelopmentGuidelines recommends at least 128
const int FREEDESKTOP_NOTIFICATION_ICON_SIZE = 128;

View file

@ -9,11 +9,12 @@
#include "bitcoin-config.h"
#endif
#include <QObject>
#include <QIcon>
#include <QObject>
QT_BEGIN_NAMESPACE
class QSystemTrayIcon;
#ifdef USE_DBUS
class QDBusInterface;
#endif

View file

@ -11,9 +11,10 @@
#include "bitcoinunits.h"
#include "monitoreddatamapper.h"
#include "netbase.h"
#include "optionsmodel.h"
#include "netbase.h"
#include <QDir>
#include <QIntValidator>
#include <QLocale>

View file

@ -7,12 +7,13 @@
#include <QDialog>
class MonitoredDataMapper;
class OptionsModel;
class QValidatedLineEdit;
namespace Ui {
class OptionsDialog;
}
class OptionsModel;
class MonitoredDataMapper;
class QValidatedLineEdit;
/** Preferences dialog. */
class OptionsDialog : public QDialog

View file

@ -9,13 +9,13 @@
#include "optionsmodel.h"
#include "bitcoinunits.h"
#include "init.h"
#include "core.h"
#include "wallet.h"
#include "netbase.h"
#include "walletdb.h"
#include "guiutil.h"
#include "init.h"
#include "main.h"
#include "net.h"
#include "walletdb.h"
#include <QSettings>
OptionsModel::OptionsModel(QObject *parent) :
@ -200,7 +200,7 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
return QVariant(5);
}
case Fee:
return QVariant(nTransactionFee);
return QVariant((qint64) nTransactionFee);
case DisplayUnit:
return QVariant(nDisplayUnit);
case DisplayAddresses:
@ -274,7 +274,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
break;
case Fee:
nTransactionFee = value.toLongLong();
settings.setValue("nTransactionFee", nTransactionFee);
settings.setValue("nTransactionFee", (qint64) nTransactionFee);
break;
case DisplayUnit:
nDisplayUnit = value.toInt();
@ -299,7 +299,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
qint64 OptionsModel::getTransactionFee()
{
return nTransactionFee;
return (qint64) nTransactionFee;
}
bool OptionsModel::getProxySettings(QString& proxyIP, quint16 &proxyPort) const

View file

@ -5,14 +5,14 @@
#include "overviewpage.h"
#include "ui_overviewpage.h"
#include "clientmodel.h"
#include "walletmodel.h"
#include "bitcoinunits.h"
#include "optionsmodel.h"
#include "transactiontablemodel.h"
#include "transactionfilterproxy.h"
#include "guiutil.h"
#include "clientmodel.h"
#include "guiconstants.h"
#include "guiutil.h"
#include "optionsmodel.h"
#include "transactionfilterproxy.h"
#include "transactiontablemodel.h"
#include "walletmodel.h"
#include <QAbstractItemDelegate>
#include <QPainter>

View file

@ -7,13 +7,14 @@
#include <QWidget>
class ClientModel;
class TransactionFilterProxy;
class TxViewDelegate;
class WalletModel;
namespace Ui {
class OverviewPage;
}
class ClientModel;
class WalletModel;
class TxViewDelegate;
class TransactionFilterProxy;
QT_BEGIN_NAMESPACE
class QModelIndex;

View file

@ -7,16 +7,16 @@
// with some extra methods
//
#include "paymentrequestplus.h"
#include <stdexcept>
#include <openssl/x509.h>
#include <openssl/x509_vfy.h>
#include <QDateTime>
#include <QDebug>
#include <QSslCertificate>
#include <openssl/x509.h>
#include <openssl/x509_vfy.h>
#include <stdexcept>
#include "paymentrequestplus.h"
class SSLVerifyError : public std::runtime_error
{

View file

@ -5,13 +5,14 @@
#ifndef PAYMENTREQUESTPLUS_H
#define PAYMENTREQUESTPLUS_H
#include "paymentrequest.pb.h"
#include "base58.h"
#include <QByteArray>
#include <QList>
#include <QString>
#include "base58.h"
#include "paymentrequest.pb.h"
//
// Wraps dumb protocol buffer paymentRequest
// with extra methods

View file

@ -2,6 +2,23 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "paymentserver.h"
#include "bitcoinunits.h"
#include "guiconstants.h"
#include "guiutil.h"
#include "optionsmodel.h"
#include "paymentserver.h"
#include "walletmodel.h"
#include "base58.h"
#include "ui_interface.h"
#include "wallet.h"
#include <cstdlib>
#include <openssl/x509.h>
#include <openssl/x509_vfy.h>
#include <QApplication>
#include <QByteArray>
#include <QDataStream>
@ -13,8 +30,6 @@
#include <QList>
#include <QLocalServer>
#include <QLocalSocket>
#include <QStringList>
#include <QTextDocument>
#include <QNetworkAccessManager>
#include <QNetworkProxy>
#include <QNetworkReply>
@ -22,27 +37,16 @@
#include <QSslCertificate>
#include <QSslError>
#include <QSslSocket>
#include <QStringList>
#include <QTextDocument>
#if QT_VERSION < 0x050000
#include <QUrl>
#else
#include <QUrlQuery>
#endif
#include <cstdlib>
#include <openssl/x509.h>
#include <openssl/x509_vfy.h>
#include "base58.h"
#include "bitcoinunits.h"
#include "guiconstants.h"
#include "guiutil.h"
#include "optionsmodel.h"
#include "paymentserver.h"
#include "ui_interface.h"
#include "util.h"
#include "wallet.h"
#include "walletmodel.h"
using namespace boost;
const int BITCOIN_IPC_CONNECT_TIMEOUT = 1000; // milliseconds
const QString BITCOIN_IPC_PREFIX("bitcoin:");
@ -357,10 +361,10 @@ void PaymentServer::handleURIOrFile(const QString& s)
if (s.startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) // bitcoin:
{
#if QT_VERSION >= 0x050000
QUrlQuery uri((QUrl(s)));
#else
#if QT_VERSION < 0x050000
QUrl uri(s);
#else
QUrlQuery uri((QUrl(s)));
#endif
if (uri.hasQueryItem("request"))
{

View file

@ -4,8 +4,6 @@
#ifndef PAYMENTSERVER_H
#define PAYMENTSERVER_H
//
// This class handles payment requests from clicking on
// bitcoin: URIs
//
@ -32,13 +30,13 @@
// and, if a server is running in another process,
// sends them to the server.
//
#include <QObject>
#include <QString>
#include "paymentrequestplus.h"
#include "walletmodel.h"
class CWallet;
#include <QObject>
#include <QString>
class OptionsModel;
QT_BEGIN_NAMESPACE
@ -51,6 +49,8 @@ class QSslError;
class QUrl;
QT_END_NAMESPACE
class CWallet;
class PaymentServer : public QObject
{
Q_OBJECT

View file

@ -6,18 +6,20 @@
#include "ui_rpcconsole.h"
#include "clientmodel.h"
#include "bitcoinrpc.h"
#include "guiutil.h"
#include <QTime>
#include <QThread>
#include "bitcoinrpc.h"
#include "json/json_spirit_value.h"
#include <openssl/crypto.h>
#include <QKeyEvent>
#include <QScrollBar>
#include <QThread>
#include <QTime>
#if QT_VERSION < 0x050000
#include <QUrl>
#endif
#include <QScrollBar>
#include <openssl/crypto.h>
// TODO: add a scrollback limit, as there is currently none
// TODO: make it possible to filter out categories (esp debug messages when implemented)

View file

@ -7,10 +7,11 @@
#include <QDialog>
class ClientModel;
namespace Ui {
class RPCConsole;
}
class ClientModel;
/** Local Bitcoin RPC console. */
class RPCConsole: public QDialog

View file

@ -6,16 +6,17 @@
#include "ui_sendcoinsdialog.h"
#include "bitcoinunits.h"
#include "guiutil.h"
#include "optionsmodel.h"
#include "sendcoinsentry.h"
#include "guiutil.h"
#include "askpassphrasedialog.h"
#include "walletmodel.h"
#include "base58.h"
#include "ui_interface.h"
#include <QMessageBox>
#include <QTextDocument>
#include <QScrollBar>
#include <QTextDocument>
SendCoinsDialog::SendCoinsDialog(QWidget *parent) :
QDialog(parent),
@ -324,7 +325,7 @@ bool SendCoinsDialog::handlePaymentRequest(const SendCoinsRecipient &rv)
if (rv.paymentRequest.IsInitialized()) {
// Expired payment request?
const payments::PaymentDetails& details = rv.paymentRequest.getDetails();
if (details.has_expires() && (int64)details.expires() < GetTime())
if (details.has_expires() && (int64_t)details.expires() < GetTime())
{
emit message(strSendCoins, tr("Payment request expired"),
CClientUIInterface::MSG_WARNING);

View file

@ -8,12 +8,8 @@
#include "walletmodel.h"
#include <QDialog>
#include <QVariant>
#include <QPair>
namespace Ui {
class SendCoinsDialog;
}
class OptionsModel;
class SendCoinsEntry;
class SendCoinsRecipient;
@ -21,6 +17,10 @@ QT_BEGIN_NAMESPACE
class QUrl;
QT_END_NAMESPACE
namespace Ui {
class SendCoinsDialog;
}
/** Dialog for sending bitcoins */
class SendCoinsDialog : public QDialog
{

View file

@ -5,12 +5,11 @@
#include "sendcoinsentry.h"
#include "ui_sendcoinsentry.h"
#include "guiutil.h"
#include "bitcoinunits.h"
#include "addressbookpage.h"
#include "walletmodel.h"
#include "optionsmodel.h"
#include "addresstablemodel.h"
#include "guiutil.h"
#include "optionsmodel.h"
#include "walletmodel.h"
#include <QApplication>
#include <QClipboard>

View file

@ -5,14 +5,15 @@
#ifndef SENDCOINSENTRY_H
#define SENDCOINSENTRY_H
#include "walletmodel.h"
#include <QStackedWidget>
#include "walletmodel.h"
class WalletModel;
namespace Ui {
class SendCoinsEntry;
}
class WalletModel;
/**
* A single entry in the dialog for sending bitcoins.

View file

@ -6,19 +6,18 @@
#include "ui_signverifymessagedialog.h"
#include "addressbookpage.h"
#include "base58.h"
#include "guiutil.h"
#include "init.h"
#include "main.h"
#include "optionsmodel.h"
#include "walletmodel.h"
#include "wallet.h"
#include <QClipboard>
#include "base58.h"
#include "init.h"
#include "wallet.h"
#include <string>
#include <vector>
#include <QClipboard>
SignVerifyMessageDialog::SignVerifyMessageDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SignVerifyMessageDialog),

View file

@ -7,10 +7,11 @@
#include <QDialog>
class WalletModel;
namespace Ui {
class SignVerifyMessageDialog;
}
class WalletModel;
class SignVerifyMessageDialog : public QDialog
{

View file

@ -3,9 +3,10 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "splashscreen.h"
#include "chainparams.h"
#include "clientversion.h"
#include "util.h"
#include "chainparams.h"
#include <QApplication>
#include <QPainter>

View file

@ -1,17 +1,17 @@
#include <QCoreApplication>
#include <QDebug>
#include <QTemporaryFile>
#include <QVariant>
#include <QFileOpenEvent>
#include "paymentservertests.h"
#include "optionsmodel.h"
#include "paymentrequestdata.h"
#include "util.h"
#include <openssl/x509.h>
#include <openssl/x509_vfy.h>
#include "optionsmodel.h"
#include "paymentservertests.h"
#include "paymentrequestdata.h"
#include "util.h"
#include <QCoreApplication>
#include <QDebug>
#include <QFileOpenEvent>
#include <QTemporaryFile>
#include <QVariant>
X509 *parse_b64der_cert(const char* cert_data)

View file

@ -1,11 +1,11 @@
#ifndef PAYMENTSERVERTESTS_H
#define PAYMENTSERVERTESTS_H
#include <QTest>
#include <QObject>
#include "../paymentserver.h"
#include <QObject>
#include <QTest>
class PaymentServerTests : public QObject
{
Q_OBJECT

View file

@ -1,8 +1,10 @@
#include <QTest>
#include <QObject>
#include "uritests.h"
#include "paymentservertests.h"
#include "uritests.h"
#include <QObject>
#include <QTest>
// This is all you need to run all the tests
int main(int argc, char *argv[])

View file

@ -1,6 +1,7 @@
#include "uritests.h"
#include "../guiutil.h"
#include "../walletmodel.h"
#include "guiutil.h"
#include "walletmodel.h"
#include <QUrl>

Some files were not shown because too many files have changed in this diff Show more