mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
update bitcoin core to git ce148944c7
This commit is contained in:
parent
0424613ba2
commit
18cf214528
@ -38,6 +38,8 @@ inline std::string EncodeBase58(const unsigned char* pbegin, const unsigned char
|
|||||||
|
|
||||||
// Convert bignum to std::string
|
// Convert bignum to std::string
|
||||||
std::string str;
|
std::string str;
|
||||||
|
// Expected size increase from base58 conversion is approximately 137%
|
||||||
|
// use 138% to be safe
|
||||||
str.reserve((pend - pbegin) * 138 / 100 + 1);
|
str.reserve((pend - pbegin) * 138 / 100 + 1);
|
||||||
CBigNum dv;
|
CBigNum dv;
|
||||||
CBigNum rem;
|
CBigNum rem;
|
||||||
|
@ -228,10 +228,13 @@ public:
|
|||||||
{
|
{
|
||||||
std::vector<unsigned char> vch2(vch.size() + 4);
|
std::vector<unsigned char> vch2(vch.size() + 4);
|
||||||
unsigned int nSize = vch.size();
|
unsigned int nSize = vch.size();
|
||||||
|
// BIGNUM's byte stream format expects 4 bytes of
|
||||||
|
// big endian size data info at the front
|
||||||
vch2[0] = (nSize >> 24) & 0xff;
|
vch2[0] = (nSize >> 24) & 0xff;
|
||||||
vch2[1] = (nSize >> 16) & 0xff;
|
vch2[1] = (nSize >> 16) & 0xff;
|
||||||
vch2[2] = (nSize >> 8) & 0xff;
|
vch2[2] = (nSize >> 8) & 0xff;
|
||||||
vch2[3] = (nSize >> 0) & 0xff;
|
vch2[3] = (nSize >> 0) & 0xff;
|
||||||
|
// swap data to big endian
|
||||||
reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4);
|
reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4);
|
||||||
BN_mpi2bn(&vch2[0], vch2.size(), this);
|
BN_mpi2bn(&vch2[0], vch2.size(), this);
|
||||||
}
|
}
|
||||||
|
11
src/db.cpp
11
src/db.cpp
@ -845,12 +845,11 @@ bool LoadWallet(bool& fFirstRunRet)
|
|||||||
{
|
{
|
||||||
// Create new keyUser and set as default key
|
// Create new keyUser and set as default key
|
||||||
RandAddSeedPerfmon();
|
RandAddSeedPerfmon();
|
||||||
keyUser.MakeNewKey();
|
|
||||||
if (!AddKey(keyUser))
|
CWalletDB walletdb;
|
||||||
return false;
|
vchDefaultKey = GetKeyFromKeyPool();
|
||||||
if (!SetAddressBookName(PubKeyToAddress(keyUser.GetPubKey()), ""))
|
walletdb.WriteDefaultKey(vchDefaultKey);
|
||||||
return false;
|
walletdb.WriteName(PubKeyToAddress(vchDefaultKey), "");
|
||||||
CWalletDB().WriteDefaultKey(keyUser.GetPubKey());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateThread(ThreadFlushWalletDB, NULL);
|
CreateThread(ThreadFlushWalletDB, NULL);
|
||||||
|
@ -139,7 +139,6 @@ bool AppInit2(int argc, char* argv[])
|
|||||||
|
|
||||||
if (mapArgs.count("-?") || mapArgs.count("--help"))
|
if (mapArgs.count("-?") || mapArgs.count("--help"))
|
||||||
{
|
{
|
||||||
string beta = VERSION_IS_BETA ? _(" beta") : "";
|
|
||||||
string strUsage = string() +
|
string strUsage = string() +
|
||||||
_("Bitcoin version") + " " + FormatFullVersion() + "\n\n" +
|
_("Bitcoin version") + " " + FormatFullVersion() + "\n\n" +
|
||||||
_("Usage:") + "\t\t\t\t\t\t\t\t\t\t\n" +
|
_("Usage:") + "\t\t\t\t\t\t\t\t\t\t\n" +
|
||||||
@ -154,6 +153,7 @@ bool AppInit2(int argc, char* argv[])
|
|||||||
" -gen=0 \t\t " + _("Don't generate coins\n") +
|
" -gen=0 \t\t " + _("Don't generate coins\n") +
|
||||||
" -min \t\t " + _("Start minimized\n") +
|
" -min \t\t " + _("Start minimized\n") +
|
||||||
" -datadir=<dir> \t\t " + _("Specify data directory\n") +
|
" -datadir=<dir> \t\t " + _("Specify data directory\n") +
|
||||||
|
" -timeout=<n> \t " + _("Specify connection timeout (in milliseconds)\n") +
|
||||||
" -proxy=<ip:port> \t " + _("Connect through socks4 proxy\n") +
|
" -proxy=<ip:port> \t " + _("Connect through socks4 proxy\n") +
|
||||||
" -dns \t " + _("Allow DNS lookups for addnode and connect\n") +
|
" -dns \t " + _("Allow DNS lookups for addnode and connect\n") +
|
||||||
" -addnode=<ip> \t " + _("Add a node to connect to\n") +
|
" -addnode=<ip> \t " + _("Add a node to connect to\n") +
|
||||||
@ -418,6 +418,13 @@ bool AppInit2(int argc, char* argv[])
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mapArgs.count("-timeout"))
|
||||||
|
{
|
||||||
|
int nNewTimeout = GetArg("-timeout", 5000);
|
||||||
|
if (nNewTimeout > 0 && nNewTimeout < 600000)
|
||||||
|
nConnectTimeout = nNewTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
if (mapArgs.count("-printblock"))
|
if (mapArgs.count("-printblock"))
|
||||||
{
|
{
|
||||||
string strMatch = mapArgs["-printblock"];
|
string strMatch = mapArgs["-printblock"];
|
||||||
|
@ -29,8 +29,8 @@ static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2;
|
|||||||
static const int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
|
static const int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
|
||||||
static const int64 COIN = 100000000;
|
static const int64 COIN = 100000000;
|
||||||
static const int64 CENT = 1000000;
|
static const int64 CENT = 1000000;
|
||||||
static const int64 MIN_TX_FEE = CENT;
|
static const int64 MIN_TX_FEE = 50000;
|
||||||
static const int64 MIN_RELAY_TX_FEE = 50000;
|
static const int64 MIN_RELAY_TX_FEE = 10000;
|
||||||
static const int64 MAX_MONEY = 21000000 * COIN;
|
static const int64 MAX_MONEY = 21000000 * COIN;
|
||||||
inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
|
inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
|
||||||
static const int COINBASE_MATURITY = 100;
|
static const int COINBASE_MATURITY = 100;
|
||||||
@ -79,7 +79,6 @@ extern int fUseUPnP;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool CheckDiskSpace(uint64 nAdditionalBytes=0);
|
bool CheckDiskSpace(uint64 nAdditionalBytes=0);
|
||||||
FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb");
|
FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb");
|
||||||
FILE* AppendBlockFile(unsigned int& nFileRet);
|
FILE* AppendBlockFile(unsigned int& nFileRet);
|
||||||
|
91
src/net.cpp
91
src/net.cpp
@ -51,6 +51,7 @@ map<CInv, int64> mapAlreadyAskedFor;
|
|||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
int fUseProxy = false;
|
int fUseProxy = false;
|
||||||
|
int nConnectTimeout = 5000;
|
||||||
CAddress addrProxy("127.0.0.1",9050);
|
CAddress addrProxy("127.0.0.1",9050);
|
||||||
|
|
||||||
|
|
||||||
@ -76,7 +77,7 @@ void CNode::PushGetBlocks(CBlockIndex* pindexBegin, uint256 hashEnd)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet)
|
bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet, int nTimeout)
|
||||||
{
|
{
|
||||||
hSocketRet = INVALID_SOCKET;
|
hSocketRet = INVALID_SOCKET;
|
||||||
|
|
||||||
@ -91,7 +92,86 @@ bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet)
|
|||||||
bool fProxy = (fUseProxy && addrConnect.IsRoutable());
|
bool fProxy = (fUseProxy && addrConnect.IsRoutable());
|
||||||
struct sockaddr_in sockaddr = (fProxy ? addrProxy.GetSockAddr() : addrConnect.GetSockAddr());
|
struct sockaddr_in sockaddr = (fProxy ? addrProxy.GetSockAddr() : addrConnect.GetSockAddr());
|
||||||
|
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
u_long fNonblock = 1;
|
||||||
|
if (ioctlsocket(hSocket, FIONBIO, &fNonblock) == SOCKET_ERROR)
|
||||||
|
#else
|
||||||
|
int fFlags = fcntl(hSocket, F_GETFL, 0);
|
||||||
|
if (fcntl(hSocket, F_SETFL, fFlags | O_NONBLOCK) == -1)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
closesocket(hSocket);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (connect(hSocket, (struct sockaddr*)&sockaddr, sizeof(sockaddr)) == SOCKET_ERROR)
|
if (connect(hSocket, (struct sockaddr*)&sockaddr, sizeof(sockaddr)) == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
// WSAEINVAL is here because some legacy version of winsock uses it
|
||||||
|
if (WSAGetLastError() == WSAEINPROGRESS || WSAGetLastError() == WSAEWOULDBLOCK || WSAGetLastError() == WSAEINVAL)
|
||||||
|
{
|
||||||
|
struct timeval timeout;
|
||||||
|
timeout.tv_sec = nTimeout / 1000;
|
||||||
|
timeout.tv_usec = (nTimeout % 1000) * 1000;
|
||||||
|
|
||||||
|
fd_set fdset;
|
||||||
|
FD_ZERO(&fdset);
|
||||||
|
FD_SET(hSocket, &fdset);
|
||||||
|
int nRet = select(hSocket + 1, NULL, &fdset, NULL, &timeout);
|
||||||
|
if (nRet == 0)
|
||||||
|
{
|
||||||
|
printf("connection timeout\n");
|
||||||
|
closesocket(hSocket);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (nRet == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
printf("select() for connection failed: %i\n",WSAGetLastError());
|
||||||
|
closesocket(hSocket);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
socklen_t nRetSize = sizeof(nRet);
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, (char*)(&nRet), &nRetSize) == SOCKET_ERROR)
|
||||||
|
#else
|
||||||
|
if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, &nRet, &nRetSize) == SOCKET_ERROR)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
printf("getsockopt() for connection failed: %i\n",WSAGetLastError());
|
||||||
|
closesocket(hSocket);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (nRet != 0)
|
||||||
|
{
|
||||||
|
printf("connect() failed after select(): %i\n",nRet);
|
||||||
|
closesocket(hSocket);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
else if (WSAGetLastError() != WSAEISCONN)
|
||||||
|
#else
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
printf("connect() failed: %s\n",WSAGetLastError());
|
||||||
|
closesocket(hSocket);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
this isn't even strictly necessary
|
||||||
|
CNode::ConnectNode immediately turns the socket back to non-blocking
|
||||||
|
but we'll turn it back to blocking just in case
|
||||||
|
*/
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
fNonblock = 0;
|
||||||
|
if (ioctlsocket(hSocket, FIONBIO, &fNonblock) == SOCKET_ERROR)
|
||||||
|
#else
|
||||||
|
fFlags = fcntl(hSocket, F_GETFL, 0);
|
||||||
|
if (fcntl(hSocket, F_SETFL, fFlags & !O_NONBLOCK) == SOCKET_ERROR)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
closesocket(hSocket);
|
closesocket(hSocket);
|
||||||
return false;
|
return false;
|
||||||
@ -756,9 +836,12 @@ void ThreadSocketHandler2(void* parg)
|
|||||||
if (nSelect == SOCKET_ERROR)
|
if (nSelect == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
int nErr = WSAGetLastError();
|
int nErr = WSAGetLastError();
|
||||||
printf("socket select error %d\n", nErr);
|
if (hSocketMax > -1)
|
||||||
for (int i = 0; i <= hSocketMax; i++)
|
{
|
||||||
FD_SET(i, &fdsetRecv);
|
printf("socket select error %d\n", nErr);
|
||||||
|
for (int i = 0; i <= hSocketMax; i++)
|
||||||
|
FD_SET(i, &fdsetRecv);
|
||||||
|
}
|
||||||
FD_ZERO(&fdsetSend);
|
FD_ZERO(&fdsetSend);
|
||||||
FD_ZERO(&fdsetError);
|
FD_ZERO(&fdsetError);
|
||||||
Sleep(timeout.tv_usec/1000);
|
Sleep(timeout.tv_usec/1000);
|
||||||
|
@ -19,6 +19,7 @@ class CRequestTracker;
|
|||||||
class CNode;
|
class CNode;
|
||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
extern int nBestHeight;
|
extern int nBestHeight;
|
||||||
|
extern int nConnectTimeout;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ enum
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet);
|
bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet, int nTimeout=nConnectTimeout);
|
||||||
bool Lookup(const char *pszName, std::vector<CAddress>& vaddr, int nServices, int nMaxSolutions, bool fAllowLookup = false, int portDefault = 0, bool fAllowPort = false);
|
bool Lookup(const char *pszName, std::vector<CAddress>& vaddr, int nServices, int nMaxSolutions, bool fAllowLookup = false, int portDefault = 0, bool fAllowPort = false);
|
||||||
bool Lookup(const char *pszName, CAddress& addr, int nServices, bool fAllowLookup = false, int portDefault = 0, bool fAllowPort = false);
|
bool Lookup(const char *pszName, CAddress& addr, int nServices, bool fAllowLookup = false, int portDefault = 0, bool fAllowPort = false);
|
||||||
bool GetMyExternalIP(unsigned int& ipRet);
|
bool GetMyExternalIP(unsigned int& ipRet);
|
||||||
|
@ -105,6 +105,8 @@ T* alignup(T* p)
|
|||||||
typedef int socklen_t;
|
typedef int socklen_t;
|
||||||
#else
|
#else
|
||||||
#define WSAGetLastError() errno
|
#define WSAGetLastError() errno
|
||||||
|
#define WSAEINVAL EINVAL
|
||||||
|
#define WSAEALREADY EALREADY
|
||||||
#define WSAEWOULDBLOCK EWOULDBLOCK
|
#define WSAEWOULDBLOCK EWOULDBLOCK
|
||||||
#define WSAEMSGSIZE EMSGSIZE
|
#define WSAEMSGSIZE EMSGSIZE
|
||||||
#define WSAEINTR EINTR
|
#define WSAEINTR EINTR
|
||||||
|
Loading…
Reference in New Issue
Block a user