Merge branch 'svost-patch'
authorCryptoManiac <balthazar@yandex.ru>
Sat, 5 Mar 2016 17:46:14 +0000 (20:46 +0300)
committerCryptoManiac <balthazar@yandex.ru>
Sat, 5 Mar 2016 17:46:14 +0000 (20:46 +0300)
src/key.h
src/main.cpp
src/net.cpp
src/netbase.cpp
src/script.h
src/util.cpp
src/util.h
src/wallet.cpp

index 3f9d8f1..c3dea57 100644 (file)
--- a/src/key.h
+++ b/src/key.h
@@ -203,7 +203,7 @@ public:
     // Calculate G*m + q
     bool ECMULGEN(const CBigNum &bnMultiplier, const CPoint &qPoint);
 
-    bool IsInfinity() { return EC_POINT_is_at_infinity(group, point); }
+    bool IsInfinity() { return EC_POINT_is_at_infinity(group, point) != 0; }
 };
 
 class CMalleablePubKey
index f8af9df..3ab03f2 100644 (file)
@@ -2347,9 +2347,9 @@ bool CBlock::AcceptBlock()
         return DoS(100, error("AcceptBlock() : incorrect %s", IsProofOfWork() ? "proof-of-work" : "proof-of-stake"));
 
     int64_t nMedianTimePast = pindexPrev->GetMedianTimePast();
-    int nMaxOffset = 12 * 3600; // 12 hours
+    int nMaxOffset = 12 * nOneHour; // 12 hours
     if (fTestNet || pindexPrev->nTime < 1450569600)
-        nMaxOffset = 7 * 86400; // One week (permanently on testNet or until 20 Dec, 2015 on mainNet)
+        nMaxOffset = 7 * nOneWeek; // One week (permanently on testNet or until 20 Dec, 2015 on mainNet)
 
     // Check timestamp against prev
     if (GetBlockTime() <= nMedianTimePast || FutureDrift(GetBlockTime()) < pindexPrev->GetBlockTime())
index d872c7c..756e5cb 100644 (file)
@@ -1181,7 +1181,6 @@ void ThreadOpenConnections2(void* parg)
                 // it'll get a pile of addresses with newer timestamps.
                 // Seed nodes are given a random 'last seen time' of between one and two
                 // weeks ago.
-                const int64_t nOneWeek = 7*24*60*60;
                 struct in_addr ip;
                 memcpy(&ip, &pnSeed[i], sizeof(ip));
                 CAddress addr(CService(ip, GetDefaultPort()));
@@ -1197,7 +1196,6 @@ void ThreadOpenConnections2(void* parg)
             std::vector<CAddress> vAdd;
             for (unsigned int i = 0; i < ARRAYLEN(pchTorSeed); i++)
             {
-                const int64_t nOneWeek = 7*24*60*60;
                 CAddress addr(CService(pchTorSeed[i], GetDefaultPort()));
                 addr.nTime = GetTime()-GetRand(nOneWeek)-nOneWeek;
                 vAdd.push_back(addr);
index 9bf5fe9..4699abf 100644 (file)
@@ -221,11 +221,9 @@ bool static Socks5(string strDest, uint16_t port, SOCKET& hSocket)
         CloseSocket(hSocket);
         return error("Hostname too long");
     }
-    char pszSocks5Init[] = "\5\1\0";
-    ssize_t nSize = sizeof(pszSocks5Init) - 1;
-
-    ssize_t ret = send(hSocket, pszSocks5Init, nSize, MSG_NOSIGNAL);
-    if (ret != nSize)
+    const char pszSocks5Init[] = "\5\1\0";
+        ssize_t ret = send(hSocket, pszSocks5Init, 3, MSG_NOSIGNAL);
+    if (ret != 3)
     {
         CloseSocket(hSocket);
         return error("Error sending to proxy");
@@ -1193,4 +1191,4 @@ bool CloseSocket(SOCKET& hSocket)
 #endif
     hSocket = INVALID_SOCKET;
     return ret != SOCKET_ERROR;
-}
\ No newline at end of file
+}
index 2ff2325..00b0525 100644 (file)
@@ -19,28 +19,28 @@ class CTransaction;
 
 static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes
 
-/* Setting nSequence to this value for every input in a transaction
- * disables nLockTime. */
+// Setting nSequence to this value for every input in a transaction
+// disables nLockTime.
 static const uint32_t SEQUENCE_FINAL = 0xffffffff;
 
-/* Threshold for inverted nSequence: below this value it is interpreted
- * as a relative lock-time, otherwise ignored. */
-static const uint32_t SEQUENCE_THRESHOLD = (1 << 31);
+// Threshold for inverted nSequence: below this value it is interpreted
+// as a relative lock-time, otherwise ignored.
+//static const uint32_t SEQUENCE_THRESHOLD = 0x80000000;
 
-/* If this flag set, CTxIn::nSequence is NOT interpreted as a
- * relative lock-time. */
-static const uint32_t SEQUENCE_LOCKTIME_DISABLE_FLAG = (1 << 31);
+// If this flag set, CTxIn::nSequence is NOT interpreted as a
+// relative lock-time.
+static const uint32_t SEQUENCE_LOCKTIME_DISABLE_FLAG = 0x80000000;
 
-/* If CTxIn::nSequence encodes a relative lock-time and this flag
- * is set, the relative lock-time has units of 512 seconds,
- * otherwise it specifies blocks with a granularity of 1. */
-static const uint32_t SEQUENCE_LOCKTIME_TYPE_FLAG = (1 << 22);
+// If CTxIn::nSequence encodes a relative lock-time and this flag
+// is set, the relative lock-time has units of 512 seconds,
+// otherwise it specifies blocks with a granularity of 1.
+static const uint32_t SEQUENCE_LOCKTIME_TYPE_FLAG = 0x00400000;
 
-/* If CTxIn::nSequence encodes a relative lock-time, this mask is
- * applied to extract that lock-time from the sequence field. */
+// If CTxIn::nSequence encodes a relative lock-time, this mask is
+// applied to extract that lock-time from the sequence field.
 static const uint32_t SEQUENCE_LOCKTIME_MASK = 0x0000ffff;
 
-/** IsMine() return codes */
+// IsMine() return codes
 enum isminetype
 {
     MINE_NO = 0,
@@ -51,7 +51,7 @@ enum isminetype
 
 typedef uint8_t isminefilter;
 
-/** Signature hash types/flags */
+// Signature hash types/flags
 enum
 {
     SIGHASH_ALL = 1,
@@ -60,7 +60,7 @@ enum
     SIGHASH_ANYONECANPAY = 0x80
 };
 
-/** Script verification flags */
+// Script verification flags
 enum
 {
     SCRIPT_VERIFY_NONE      = 0,
@@ -68,7 +68,7 @@ enum
     SCRIPT_VERIFY_STRICTENC = (1U << 1), // enforce strict conformance to DER and SEC2 for signatures and pubkeys
     SCRIPT_VERIFY_LOW_S     = (1U << 2), // enforce low S values in signatures (depends on STRICTENC)
     SCRIPT_VERIFY_NOCACHE   = (1U << 3), // do not store results in signature cache (but do query it)
-    SCRIPT_VERIFY_NULLDUMMY = (1U << 4),  // verify dummy stack item consumed by CHECKMULTISIG is of zero-length
+    SCRIPT_VERIFY_NULLDUMMY = (1U << 4), // verify dummy stack item consumed by CHECKMULTISIG is of zero-length
     SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY = (1U << 9),
     SCRIPT_VERIFY_CHECKSEQUENCEVERIFY = (1U << 10)
 };
@@ -108,7 +108,7 @@ enum txnouttype
 
 const char* GetTxnOutputType(txnouttype t);
 
-/** Script opcodes */
+// Script opcodes
 enum opcodetype
 {
     // push value
@@ -276,7 +276,7 @@ inline std::string StackString(const std::vector<std::vector<unsigned char> >& v
     return str;
 }
 
-/** Serialized script, used inside transaction inputs and outputs */
+// Serialized script, used inside transaction inputs and outputs
 class CScript : public std::vector<uint8_t>
 {
 protected:
index 0f84938..a3848fd 100644 (file)
@@ -408,16 +408,16 @@ string FormatMoney(int64_t n, bool fPlus)
     string str = strprintf("%" PRId64 ".%06" PRId64, quotient, remainder);
 
     // Right-trim excess zeros before the decimal point:
-    int nTrim = 0;
+    size_t nTrim = 0;
     for (size_t i = str.size()-1; (str[i] == '0' && isdigit(str[i-2])); --i)
         ++nTrim;
     if (nTrim)
         str.erase(str.size()-nTrim, nTrim);
 
     if (n < 0)
-        str.insert((unsigned int)0, 1, '-');
+        str.insert(0u, 1, '-');
     else if (fPlus && n > 0)
-        str.insert((unsigned int)0, 1, '+');
+        str.insert(0u, 1, '+');
     return str;
 }
 
@@ -1500,4 +1500,4 @@ std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime)
     ss.imbue(loc);
     ss << boost::posix_time::from_time_t(nTime);
     return ss.str();
-}
\ No newline at end of file
+}
index f4b872c..c8ae742 100644 (file)
@@ -37,6 +37,7 @@
 
 static const int32_t nOneHour = 60 * 60;
 static const int32_t nOneDay = 24 * 60 * 60;
+static const int64_t nOneWeek = 7 * 24 * 60 * 60;
 
 static const int64_t COIN = 1000000;
 static const int64_t CENT = 10000;
index c720615..ee601ca 100644 (file)
@@ -2121,7 +2121,6 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
             AddToWallet(wtxNew);
 
             // Mark old coins as spent
-            set<CWalletTx*> setCoins;
             BOOST_FOREACH(const CTxIn& txin, wtxNew.vin)
             {
                 CWalletTx &coin = mapWallet[txin.prevout.hash];