}
+// Closure representing one script verification
+// Note that this stores references to the spending transaction
+class CScriptCheck
+{
+private:
+ CScript scriptPubKey;
+ const CTransaction *ptxTo = nullptr;
+ uint32_t nIn = 0;
+ unsigned int nFlags = 0;
+ int nHashType = 0;
+
+public:
+ CScriptCheck() {}
+ CScriptCheck(const CTransaction& txFromIn, const CTransaction& txToIn, uint32_t nInIn, unsigned int nFlagsIn, int nHashTypeIn) :
+ scriptPubKey(txFromIn.vout[txToIn.vin[nInIn].prevout.n].scriptPubKey),
+ ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), nHashType(nHashTypeIn) { }
+ bool operator()() const;
+ void swap(CScriptCheck &check) {
+ scriptPubKey.swap(check.scriptPubKey);
+ std::swap(ptxTo, check.ptxTo);
+ std::swap(nIn, check.nIn);
+ std::swap(nFlags, check.nFlags);
+ std::swap(nHashType, check.nHashType);
+ }
+};
const CTxOut& GetOutputFor(const CTxIn& input, const MapPrevTx& inputs) const;
};
-/** Closure representing one script verification
- * Note that this stores references to the spending transaction */
-class CScriptCheck
-{
-private:
- CScript scriptPubKey;
- const CTransaction *ptxTo = nullptr;
- uint32_t nIn = 0;
- unsigned int nFlags = 0;
- int nHashType = 0;
-
-public:
- CScriptCheck() {}
- CScriptCheck(const CTransaction& txFromIn, const CTransaction& txToIn, uint32_t nInIn, unsigned int nFlagsIn, int nHashTypeIn) :
- scriptPubKey(txFromIn.vout[txToIn.vin[nInIn].prevout.n].scriptPubKey),
- ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), nHashType(nHashTypeIn) { }
-
- bool operator()() const;
-
- void swap(CScriptCheck &check) {
- scriptPubKey.swap(check.scriptPubKey);
- std::swap(ptxTo, check.ptxTo);
- std::swap(nIn, check.nIn);
- std::swap(nFlags, check.nFlags);
- std::swap(nHashType, check.nHashType);
- }
-};
-
#include "addrman.h"
#include "hash.h"
-using namespace std;
class CRequestTracker;
class CNode;
inline uint64_t ReceiveBufferSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); }
inline uint64_t SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 1*1000); }
-void AddOneShot(string strDest);
-bool RecvLine(SOCKET hSocket, string& strLine);
+void AddOneShot(std::string strDest);
+bool RecvLine(SOCKET hSocket, std::string& strLine);
bool GetMyExternalIP(CNetAddr& ipRet);
void AddressCurrentlyConnected(const CService& addr);
CNode* FindNode(const CNetAddr& ip);
CNode* ConnectNode(CAddress addrConnect, const char *strDest = NULL, int64_t nTimeout=0);
bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false);
uint16_t GetListenPort();
-bool BindListenPort(const CService &bindAddr, string& strError=REF(string()));
+bool BindListenPort(const CService &bindAddr, std::string& strError=REF(std::string()));
void StartNode(void* parg);
bool StopNode();
extern uint64_t nLocalServices;
extern uint64_t nLocalHostNonce;
extern CAddress addrSeenByPeer;
-extern array<int, THREAD_MAX> vnThreadsRunning;
+extern std::array<int, THREAD_MAX> vnThreadsRunning;
extern CAddrMan addrman;
-extern vector<CNode*> vNodes;
+extern std::vector<CNode*> vNodes;
extern CCriticalSection cs_vNodes;
-extern vector<string> vAddedNodes;
+extern std::vector<std::string> vAddedNodes;
extern CCriticalSection cs_vAddedNodes;
-extern map<CInv, CDataStream> mapRelay;
-extern deque<pair<int64_t, CInv> > vRelayExpiration;
+extern std::map<CInv, CDataStream> mapRelay;
+extern std::deque<std::pair<int64_t, CInv> > vRelayExpiration;
extern CCriticalSection cs_mapRelay;
-extern map<CInv, int64_t> mapAlreadyAskedFor;
+extern std::map<CInv, int64_t> mapAlreadyAskedFor;
class CNodeStats
int64_t nLastSend;
int64_t nLastRecv;
int64_t nTimeConnected;
- string addrName;
+ std::string addrName;
int32_t nVersion;
- string strSubVer;
+ std::string strSubVer;
bool fInbound;
int64_t nReleaseTime;
int32_t nStartingHeight;
int32_t nHeaderStart;
uint32_t nMessageStart;
CAddress addr;
- string addrName;
+ std::string addrName;
CService addrLocal;
int32_t nVersion;
- string strSubVer;
+ std::string strSubVer;
bool fOneShot;
bool fClient;
bool fInbound;
// Denial-of-service detection/prevention
// Key is IP address, value is banned-until-time
- static map<CNetAddr, int64_t> setBanned;
+ static std::map<CNetAddr, int64_t> setBanned;
static CCriticalSection cs_setBanned;
int nMisbehavior;
public:
int64_t nReleaseTime;
- map<uint256, CRequestTracker> mapRequests;
+ std::map<uint256, CRequestTracker> mapRequests;
CCriticalSection cs_mapRequests;
uint256 hashContinue;
CBlockIndex* pindexLastGetBlocksBegin;
bool fStartSync;
// flood relay
- vector<CAddress> vAddrToSend;
- set<CAddress> setAddrKnown;
+ std::vector<CAddress> vAddrToSend;
+ std::set<CAddress> setAddrKnown;
bool fGetAddr;
- set<uint256> setKnown;
+ std::set<uint256> setKnown;
uint256 hashCheckpointKnown; // ppcoin: known sent sync-checkpoint
int64_t nNextAddrSend;
int64_t nNextLocalAddrSend;
// inventory based relay
mruset<CInv> setInventoryKnown;
- vector<CInv> vInventoryToSend;
+ std::vector<CInv> vInventoryToSend;
CCriticalSection cs_inventory;
- multimap<int64_t, CInv> mapAskFor;
+ std::multimap<int64_t, CInv> mapAskFor;
- CNode(SOCKET hSocketIn, CAddress addrIn, string addrNameIn = "", bool fInboundIn=false);
+ CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn = "", bool fInboundIn=false);
~CNode();
private:
#include "net.h"
#include "ui_interface.h"
+using namespace std;
+
extern int GetRandInt(int nMax);
/*
const int nServersCount = 162;
-std::string NtpServers[162] = {
+string NtpServers[162] = {
// Microsoft
"time.windows.com",
// ... To be continued
};
-bool InitWithHost(const std::string &strHostName, SOCKET &sockfd, socklen_t &servlen, struct sockaddr *pcliaddr) {
+bool InitWithHost(const string &strHostName, SOCKET &sockfd, socklen_t &servlen, struct sockaddr *pcliaddr) {
sockfd = INVALID_SOCKET;
- std::vector<CNetAddr> vIP;
+ vector<CNetAddr> vIP;
bool fRet = LookupHost(strHostName, vIP, 10, true);
if (!fRet) {
return false;
return nTime;
}
-int64_t NtpGetTime(const std::string &strHostName)
+int64_t NtpGetTime(const string &strHostName)
{
struct sockaddr cliaddr;
// NTP server, which we unconditionally trust. This may be your own installation of ntpd somewhere, for example.
// "localhost" means "trust no one"
-std::string strTrustedUpstream = "localhost";
+string strTrustedUpstream = "localhost";
// Current offset
int64_t nNtpOffset = numeric_limits<int64_t>::max();
printf("Trying to find NTP server at localhost...\n");
- std::string strLocalHost = "127.0.0.1";
+ string strLocalHost = "127.0.0.1";
if (NtpGetTime(strLocalHost) == GetTime()) {
printf("There is NTP server active at localhost, we don't need NTP thread.\n");
if (GetNodesOffset() == numeric_limits<int64_t>::max() && abs(nNtpOffset) > 40 * 60)
{
// If there is not enough node offsets data and NTP time offset is greater than 40 minutes then give a warning.
- std::string strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong NovaCoin will not work properly.");
+ string strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong NovaCoin will not work properly.");
strMiscWarning = strMessage;
printf("*** %s\n", strMessage.c_str());
- uiInterface.ThreadSafeMessageBox(strMessage+" ", std::string("NovaCoin"), CClientUIInterface::OK | CClientUIInterface::ICON_EXCLAMATION);
+ uiInterface.ThreadSafeMessageBox(strMessage+" ", string("NovaCoin"), CClientUIInterface::OK | CClientUIInterface::ICON_EXCLAMATION);
}
printf("nNtpOffset = %+" PRId64 " (%+" PRId64 " minutes)\n", nNtpOffset, nNtpOffset/60);
#include <iomanip>
#include <sstream>
-using namespace std;
-
/** Base class without constructors for uint256 and uint160.
* This makes the compiler let u use it in a union.
virtual const char* what() const throw () { return what_.c_str(); }
virtual ~uint256_error() throw () {}
private:
- std::string what_;
+ std::string what_;
};
/** 256-bit unsigned integer */
#define MAX_PATH 1024
inline void Sleep(int64_t n)
{
- this_thread::sleep_for(std::chrono::milliseconds(n));
+ /*Boost has a year 2038 problem— if the request sleep time is past epoch+2^31 seconds the sleep returns instantly.
+ So we clamp our sleeps here to 10 years and hope that boost is fixed by 2028.*/
+ boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(n>315576000000LL?315576000000LL:n));
}
#endif
#include "db.h"
#include "keystore.h"
-using namespace std;
class CKeyPool;
class CAccount;
class CWalletDB : public CDB
{
public:
- CWalletDB(string strFilename, const char* pszMode="r+");
+ CWalletDB(std::string strFilename, const char* pszMode="r+");
private:
CWalletDB(const CWalletDB&);
void operator=(const CWalletDB&);
public:
- bool WriteName(const string& strAddress, const string& strName);
- bool EraseName(const string& strAddress);
+ bool WriteName(const std::string& strAddress, const std::string& strName);
+ bool EraseName(const std::string& strAddress);
bool WriteTx(uint256 hash, const CWalletTx& wtx);
bool EraseTx(uint256 hash);
bool WriteKey(const CPubKey& key, const CPrivKey& vchPrivKey, const CKeyMetadata &keyMeta);
bool WriteMalleableKey(const CMalleableKeyView& keyView, const CSecret& vchSecretH, const CKeyMetadata &keyMeta);
- bool WriteCryptedMalleableKey(const CMalleableKeyView& keyView, const vector<unsigned char>& vchCryptedSecretH, const CKeyMetadata &keyMeta);
- bool WriteCryptedKey(const CPubKey& key, const vector<unsigned char>& vchCryptedSecret, const CKeyMetadata &keyMeta);
+ bool WriteCryptedMalleableKey(const CMalleableKeyView& keyView, const std::vector<unsigned char>& vchCryptedSecretH, const CKeyMetadata &keyMeta);
+ bool WriteCryptedKey(const CPubKey& key, const std::vector<unsigned char>& vchCryptedSecret, const CKeyMetadata &keyMeta);
bool WriteMasterKey(unsigned int nID, const CMasterKey& kMasterKey);
bool EraseMasterKey(unsigned int nID);
bool EraseCryptedKey(const CPubKey& key);
bool WritePool(int64_t nPool, const CKeyPool& keypool);
bool ErasePool(int64_t nPool);
bool WriteMinVersion(int nVersion);
- bool ReadAccount(const string& strAccount, CAccount& account);
- bool WriteAccount(const string& strAccount, const CAccount& account);
+ bool ReadAccount(const std::string& strAccount, CAccount& account);
+ bool WriteAccount(const std::string& strAccount, const CAccount& account);
private:
bool WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry);
public:
bool WriteAccountingEntry(const CAccountingEntry& acentry);
- int64_t GetAccountCreditDebit(const string& strAccount);
- void ListAccountCreditDebit(const string& strAccount, list<CAccountingEntry>& acentries);
+ int64_t GetAccountCreditDebit(const std::string& strAccount);
+ void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& acentries);
DBErrors ReorderTransactions(CWallet*);
DBErrors LoadWallet(CWallet* pwallet);
- DBErrors FindWalletTx(CWallet* pwallet, vector<uint256>& vTxHash);
+ DBErrors FindWalletTx(CWallet* pwallet, std::vector<uint256>& vTxHash);
DBErrors ZapWalletTx(CWallet* pwallet);
- static bool Recover(CDBEnv& dbenv, string filename, bool fOnlyKeys);
- static bool Recover(CDBEnv& dbenv, string filename);
+ static bool Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys);
+ static bool Recover(CDBEnv& dbenv, std::string filename);
};
#endif // BITCOIN_WALLETDB_H