Merge pull request #1106 from jgarzik/sign-compare
Fix many sign-comparison warnings found in bitcoin codebase
This commit is contained in:
commit
b97d54355e
17 changed files with 68 additions and 68 deletions
|
@ -124,7 +124,7 @@ int CAddrMan::SelectTried(int nKBucket)
|
||||||
// random shuffle the first few elements (using the entire list)
|
// random shuffle the first few elements (using the entire list)
|
||||||
// find the least recently tried among them
|
// find the least recently tried among them
|
||||||
int64 nOldest = -1;
|
int64 nOldest = -1;
|
||||||
for (int i=0; i<ADDRMAN_TRIED_ENTRIES_INSPECT_ON_EVICT && i<vTried.size(); i++)
|
for (unsigned int i = 0; i < ADDRMAN_TRIED_ENTRIES_INSPECT_ON_EVICT && i < vTried.size(); i++)
|
||||||
{
|
{
|
||||||
int nPos = GetRandInt(vTried.size() - i) + i;
|
int nPos = GetRandInt(vTried.size() - i) + i;
|
||||||
int nTemp = vTried[nPos];
|
int nTemp = vTried[nPos];
|
||||||
|
@ -270,7 +270,7 @@ void CAddrMan::Good_(const CService &addr, int64 nTime)
|
||||||
// find a bucket it is in now
|
// find a bucket it is in now
|
||||||
int nRnd = GetRandInt(vvNew.size());
|
int nRnd = GetRandInt(vvNew.size());
|
||||||
int nUBucket = -1;
|
int nUBucket = -1;
|
||||||
for (int n = 0; n < vvNew.size(); n++)
|
for (unsigned int n = 0; n < vvNew.size(); n++)
|
||||||
{
|
{
|
||||||
int nB = (n+nRnd) % vvNew.size();
|
int nB = (n+nRnd) % vvNew.size();
|
||||||
std::set<int> &vNew = vvNew[nB];
|
std::set<int> &vNew = vvNew[nB];
|
||||||
|
|
|
@ -288,7 +288,7 @@ public:
|
||||||
|
|
||||||
bool IsValid() const
|
bool IsValid() const
|
||||||
{
|
{
|
||||||
int nExpectedSize = 20;
|
unsigned int nExpectedSize = 20;
|
||||||
bool fExpectTestNet = false;
|
bool fExpectTestNet = false;
|
||||||
switch(nVersion)
|
switch(nVersion)
|
||||||
{
|
{
|
||||||
|
|
|
@ -201,7 +201,7 @@ Value help(const Array& params, bool fHelp)
|
||||||
// Help text is returned in an exception
|
// Help text is returned in an exception
|
||||||
string strHelp = string(e.what());
|
string strHelp = string(e.what());
|
||||||
if (strCommand == "")
|
if (strCommand == "")
|
||||||
if (strHelp.find('\n') != -1)
|
if (strHelp.find('\n') != string::npos)
|
||||||
strHelp = strHelp.substr(0, strHelp.find('\n'));
|
strHelp = strHelp.substr(0, strHelp.find('\n'));
|
||||||
strRet += strHelp + "\n";
|
strRet += strHelp + "\n";
|
||||||
}
|
}
|
||||||
|
@ -1000,7 +1000,7 @@ Value addmultisigaddress(const Array& params, bool fHelp)
|
||||||
"(got %d, need at least %d)", keys.size(), nRequired));
|
"(got %d, need at least %d)", keys.size(), nRequired));
|
||||||
std::vector<CKey> pubkeys;
|
std::vector<CKey> pubkeys;
|
||||||
pubkeys.resize(keys.size());
|
pubkeys.resize(keys.size());
|
||||||
for (int i = 0; i < keys.size(); i++)
|
for (unsigned int i = 0; i < keys.size(); i++)
|
||||||
{
|
{
|
||||||
const std::string& ks = keys[i].get_str();
|
const std::string& ks = keys[i].get_str();
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::v
|
||||||
i = EVP_BytesToKey(EVP_aes_256_cbc(), EVP_sha512(), &chSalt[0],
|
i = EVP_BytesToKey(EVP_aes_256_cbc(), EVP_sha512(), &chSalt[0],
|
||||||
(unsigned char *)&strKeyData[0], strKeyData.size(), nRounds, chKey, chIV);
|
(unsigned char *)&strKeyData[0], strKeyData.size(), nRounds, chKey, chIV);
|
||||||
|
|
||||||
if (i != WALLET_CRYPTO_KEY_SIZE)
|
if (i != (int)WALLET_CRYPTO_KEY_SIZE)
|
||||||
{
|
{
|
||||||
memset(&chKey, 0, sizeof chKey);
|
memset(&chKey, 0, sizeof chKey);
|
||||||
memset(&chIV, 0, sizeof chIV);
|
memset(&chIV, 0, sizeof chIV);
|
||||||
|
|
|
@ -108,13 +108,13 @@ int RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const cha
|
||||||
if (!RecvLineIRC(hSocket, strLine))
|
if (!RecvLineIRC(hSocket, strLine))
|
||||||
return 0;
|
return 0;
|
||||||
printf("IRC %s\n", strLine.c_str());
|
printf("IRC %s\n", strLine.c_str());
|
||||||
if (psz1 && strLine.find(psz1) != -1)
|
if (psz1 && strLine.find(psz1) != string::npos)
|
||||||
return 1;
|
return 1;
|
||||||
if (psz2 && strLine.find(psz2) != -1)
|
if (psz2 && strLine.find(psz2) != string::npos)
|
||||||
return 2;
|
return 2;
|
||||||
if (psz3 && strLine.find(psz3) != -1)
|
if (psz3 && strLine.find(psz3) != string::npos)
|
||||||
return 3;
|
return 3;
|
||||||
if (psz4 && strLine.find(psz4) != -1)
|
if (psz4 && strLine.find(psz4) != string::npos)
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ public:
|
||||||
|
|
||||||
CPrivKey GetPrivKey() const
|
CPrivKey GetPrivKey() const
|
||||||
{
|
{
|
||||||
unsigned int nSize = i2d_ECPrivateKey(pkey, NULL);
|
int nSize = i2d_ECPrivateKey(pkey, NULL);
|
||||||
if (!nSize)
|
if (!nSize)
|
||||||
throw key_error("CKey::GetPrivKey() : i2d_ECPrivateKey failed");
|
throw key_error("CKey::GetPrivKey() : i2d_ECPrivateKey failed");
|
||||||
CPrivKey vchPrivKey(nSize, 0);
|
CPrivKey vchPrivKey(nSize, 0);
|
||||||
|
@ -196,7 +196,7 @@ public:
|
||||||
|
|
||||||
std::vector<unsigned char> GetPubKey() const
|
std::vector<unsigned char> GetPubKey() const
|
||||||
{
|
{
|
||||||
unsigned int nSize = i2o_ECPublicKey(pkey, NULL);
|
int nSize = i2o_ECPublicKey(pkey, NULL);
|
||||||
if (!nSize)
|
if (!nSize)
|
||||||
throw key_error("CKey::GetPubKey() : i2o_ECPublicKey failed");
|
throw key_error("CKey::GetPubKey() : i2o_ECPublicKey failed");
|
||||||
std::vector<unsigned char> vchPubKey(nSize, 0);
|
std::vector<unsigned char> vchPubKey(nSize, 0);
|
||||||
|
|
38
src/main.cpp
38
src/main.cpp
|
@ -288,7 +288,7 @@ bool CTransaction::AreInputsStandard(const MapPrevTx& mapInputs) const
|
||||||
if (IsCoinBase())
|
if (IsCoinBase())
|
||||||
return true; // Coinbases don't use vin normally
|
return true; // Coinbases don't use vin normally
|
||||||
|
|
||||||
for (int i = 0; i < vin.size(); i++)
|
for (unsigned int i = 0; i < vin.size(); i++)
|
||||||
{
|
{
|
||||||
const CTxOut& prev = GetOutputFor(vin[i], mapInputs);
|
const CTxOut& prev = GetOutputFor(vin[i], mapInputs);
|
||||||
|
|
||||||
|
@ -484,7 +484,7 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi
|
||||||
|
|
||||||
// Check for conflicts with in-memory transactions
|
// Check for conflicts with in-memory transactions
|
||||||
CTransaction* ptxOld = NULL;
|
CTransaction* ptxOld = NULL;
|
||||||
for (int i = 0; i < vin.size(); i++)
|
for (unsigned int i = 0; i < vin.size(); i++)
|
||||||
{
|
{
|
||||||
COutPoint outpoint = vin[i].prevout;
|
COutPoint outpoint = vin[i].prevout;
|
||||||
if (mapNextTx.count(outpoint))
|
if (mapNextTx.count(outpoint))
|
||||||
|
@ -500,7 +500,7 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi
|
||||||
return false;
|
return false;
|
||||||
if (!IsNewerThan(*ptxOld))
|
if (!IsNewerThan(*ptxOld))
|
||||||
return false;
|
return false;
|
||||||
for (int i = 0; i < vin.size(); i++)
|
for (unsigned int i = 0; i < vin.size(); i++)
|
||||||
{
|
{
|
||||||
COutPoint outpoint = vin[i].prevout;
|
COutPoint outpoint = vin[i].prevout;
|
||||||
if (!mapNextTx.count(outpoint) || mapNextTx[outpoint].ptx != ptxOld)
|
if (!mapNextTx.count(outpoint) || mapNextTx[outpoint].ptx != ptxOld)
|
||||||
|
@ -603,7 +603,7 @@ bool CTransaction::AddToMemoryPoolUnchecked()
|
||||||
LOCK(cs_mapTransactions);
|
LOCK(cs_mapTransactions);
|
||||||
uint256 hash = GetHash();
|
uint256 hash = GetHash();
|
||||||
mapTransactions[hash] = *this;
|
mapTransactions[hash] = *this;
|
||||||
for (int i = 0; i < vin.size(); i++)
|
for (unsigned int i = 0; i < vin.size(); i++)
|
||||||
mapNextTx[vin[i].prevout] = CInPoint(&mapTransactions[hash], i);
|
mapNextTx[vin[i].prevout] = CInPoint(&mapTransactions[hash], i);
|
||||||
nTransactionsUpdated++;
|
nTransactionsUpdated++;
|
||||||
++nPooledTx;
|
++nPooledTx;
|
||||||
|
@ -989,7 +989,7 @@ bool CTransaction::FetchInputs(CTxDB& txdb, const map<uint256, CTxIndex>& mapTes
|
||||||
if (IsCoinBase())
|
if (IsCoinBase())
|
||||||
return true; // Coinbase transactions have no inputs to fetch.
|
return true; // Coinbase transactions have no inputs to fetch.
|
||||||
|
|
||||||
for (int i = 0; i < vin.size(); i++)
|
for (unsigned int i = 0; i < vin.size(); i++)
|
||||||
{
|
{
|
||||||
COutPoint prevout = vin[i].prevout;
|
COutPoint prevout = vin[i].prevout;
|
||||||
if (inputsRet.count(prevout.hash))
|
if (inputsRet.count(prevout.hash))
|
||||||
|
@ -1034,7 +1034,7 @@ bool CTransaction::FetchInputs(CTxDB& txdb, const map<uint256, CTxIndex>& mapTes
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure all prevout.n's are valid:
|
// Make sure all prevout.n's are valid:
|
||||||
for (int i = 0; i < vin.size(); i++)
|
for (unsigned int i = 0; i < vin.size(); i++)
|
||||||
{
|
{
|
||||||
const COutPoint prevout = vin[i].prevout;
|
const COutPoint prevout = vin[i].prevout;
|
||||||
assert(inputsRet.count(prevout.hash) != 0);
|
assert(inputsRet.count(prevout.hash) != 0);
|
||||||
|
@ -1071,7 +1071,7 @@ int64 CTransaction::GetValueIn(const MapPrevTx& inputs) const
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int64 nResult = 0;
|
int64 nResult = 0;
|
||||||
for (int i = 0; i < vin.size(); i++)
|
for (unsigned int i = 0; i < vin.size(); i++)
|
||||||
{
|
{
|
||||||
nResult += GetOutputFor(vin[i], inputs).nValue;
|
nResult += GetOutputFor(vin[i], inputs).nValue;
|
||||||
}
|
}
|
||||||
|
@ -1085,7 +1085,7 @@ int CTransaction::GetP2SHSigOpCount(const MapPrevTx& inputs) const
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int nSigOps = 0;
|
int nSigOps = 0;
|
||||||
for (int i = 0; i < vin.size(); i++)
|
for (unsigned int i = 0; i < vin.size(); i++)
|
||||||
{
|
{
|
||||||
const CTxOut& prevout = GetOutputFor(vin[i], inputs);
|
const CTxOut& prevout = GetOutputFor(vin[i], inputs);
|
||||||
if (prevout.scriptPubKey.IsPayToScriptHash())
|
if (prevout.scriptPubKey.IsPayToScriptHash())
|
||||||
|
@ -1106,7 +1106,7 @@ bool CTransaction::ConnectInputs(MapPrevTx inputs,
|
||||||
{
|
{
|
||||||
int64 nValueIn = 0;
|
int64 nValueIn = 0;
|
||||||
int64 nFees = 0;
|
int64 nFees = 0;
|
||||||
for (int i = 0; i < vin.size(); i++)
|
for (unsigned int i = 0; i < vin.size(); i++)
|
||||||
{
|
{
|
||||||
COutPoint prevout = vin[i].prevout;
|
COutPoint prevout = vin[i].prevout;
|
||||||
assert(inputs.count(prevout.hash) > 0);
|
assert(inputs.count(prevout.hash) > 0);
|
||||||
|
@ -1185,7 +1185,7 @@ bool CTransaction::ClientConnectInputs()
|
||||||
{
|
{
|
||||||
LOCK(cs_mapTransactions);
|
LOCK(cs_mapTransactions);
|
||||||
int64 nValueIn = 0;
|
int64 nValueIn = 0;
|
||||||
for (int i = 0; i < vin.size(); i++)
|
for (unsigned int i = 0; i < vin.size(); i++)
|
||||||
{
|
{
|
||||||
// Get prev tx from single transactions in memory
|
// Get prev tx from single transactions in memory
|
||||||
COutPoint prevout = vin[i].prevout;
|
COutPoint prevout = vin[i].prevout;
|
||||||
|
@ -1396,7 +1396,7 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
|
||||||
|
|
||||||
// Connect longer branch
|
// Connect longer branch
|
||||||
vector<CTransaction> vDelete;
|
vector<CTransaction> vDelete;
|
||||||
for (int i = 0; i < vConnect.size(); i++)
|
for (unsigned int i = 0; i < vConnect.size(); i++)
|
||||||
{
|
{
|
||||||
CBlockIndex* pindex = vConnect[i];
|
CBlockIndex* pindex = vConnect[i];
|
||||||
CBlock block;
|
CBlock block;
|
||||||
|
@ -1635,7 +1635,7 @@ bool CBlock::CheckBlock() const
|
||||||
// First transaction must be coinbase, the rest must not be
|
// First transaction must be coinbase, the rest must not be
|
||||||
if (vtx.empty() || !vtx[0].IsCoinBase())
|
if (vtx.empty() || !vtx[0].IsCoinBase())
|
||||||
return DoS(100, error("CheckBlock() : first tx is not coinbase"));
|
return DoS(100, error("CheckBlock() : first tx is not coinbase"));
|
||||||
for (int i = 1; i < vtx.size(); i++)
|
for (unsigned int i = 1; i < vtx.size(); i++)
|
||||||
if (vtx[i].IsCoinBase())
|
if (vtx[i].IsCoinBase())
|
||||||
return DoS(100, error("CheckBlock() : more than one coinbase"));
|
return DoS(100, error("CheckBlock() : more than one coinbase"));
|
||||||
|
|
||||||
|
@ -1771,7 +1771,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock)
|
||||||
// Recursively process any orphan blocks that depended on this one
|
// Recursively process any orphan blocks that depended on this one
|
||||||
vector<uint256> vWorkQueue;
|
vector<uint256> vWorkQueue;
|
||||||
vWorkQueue.push_back(hash);
|
vWorkQueue.push_back(hash);
|
||||||
for (int i = 0; i < vWorkQueue.size(); i++)
|
for (unsigned int i = 0; i < vWorkQueue.size(); i++)
|
||||||
{
|
{
|
||||||
uint256 hashPrev = vWorkQueue[i];
|
uint256 hashPrev = vWorkQueue[i];
|
||||||
for (multimap<uint256, CBlock*>::iterator mi = mapOrphanBlocksByPrev.lower_bound(hashPrev);
|
for (multimap<uint256, CBlock*>::iterator mi = mapOrphanBlocksByPrev.lower_bound(hashPrev);
|
||||||
|
@ -1995,7 +1995,7 @@ void PrintBlockTree()
|
||||||
|
|
||||||
// put the main timechain first
|
// put the main timechain first
|
||||||
vector<CBlockIndex*>& vNext = mapNext[pindex];
|
vector<CBlockIndex*>& vNext = mapNext[pindex];
|
||||||
for (int i = 0; i < vNext.size(); i++)
|
for (unsigned int i = 0; i < vNext.size(); i++)
|
||||||
{
|
{
|
||||||
if (vNext[i]->pnext)
|
if (vNext[i]->pnext)
|
||||||
{
|
{
|
||||||
|
@ -2005,7 +2005,7 @@ void PrintBlockTree()
|
||||||
}
|
}
|
||||||
|
|
||||||
// iterate children
|
// iterate children
|
||||||
for (int i = 0; i < vNext.size(); i++)
|
for (unsigned int i = 0; i < vNext.size(); i++)
|
||||||
vStack.push_back(make_pair(nCol+i, vNext[i]));
|
vStack.push_back(make_pair(nCol+i, vNext[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2374,7 +2374,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||||
}
|
}
|
||||||
|
|
||||||
CTxDB txdb("r");
|
CTxDB txdb("r");
|
||||||
for (int nInv = 0; nInv < vInv.size(); nInv++)
|
for (unsigned int nInv = 0; nInv < vInv.size(); nInv++)
|
||||||
{
|
{
|
||||||
const CInv &inv = vInv[nInv];
|
const CInv &inv = vInv[nInv];
|
||||||
|
|
||||||
|
@ -2550,7 +2550,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||||
vWorkQueue.push_back(inv.hash);
|
vWorkQueue.push_back(inv.hash);
|
||||||
|
|
||||||
// Recursively process any orphan transactions that depended on this one
|
// Recursively process any orphan transactions that depended on this one
|
||||||
for (int i = 0; i < vWorkQueue.size(); i++)
|
for (unsigned int i = 0; i < vWorkQueue.size(); i++)
|
||||||
{
|
{
|
||||||
uint256 hashPrev = vWorkQueue[i];
|
uint256 hashPrev = vWorkQueue[i];
|
||||||
for (multimap<uint256, CDataStream*>::iterator mi = mapOrphanTransactionsByPrev.lower_bound(hashPrev);
|
for (multimap<uint256, CDataStream*>::iterator mi = mapOrphanTransactionsByPrev.lower_bound(hashPrev);
|
||||||
|
@ -3330,7 +3330,7 @@ void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash
|
||||||
FormatHashBlocks(&tmp.hash1, sizeof(tmp.hash1));
|
FormatHashBlocks(&tmp.hash1, sizeof(tmp.hash1));
|
||||||
|
|
||||||
// Byte swap all the input buffer
|
// Byte swap all the input buffer
|
||||||
for (int i = 0; i < sizeof(tmp)/4; i++)
|
for (unsigned int i = 0; i < sizeof(tmp)/4; i++)
|
||||||
((unsigned int*)&tmp)[i] = ByteReverse(((unsigned int*)&tmp)[i]);
|
((unsigned int*)&tmp)[i] = ByteReverse(((unsigned int*)&tmp)[i]);
|
||||||
|
|
||||||
// Precalc the first half of the first hash, which stays constant
|
// Precalc the first half of the first hash, which stays constant
|
||||||
|
@ -3455,7 +3455,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||||
// Check if something found
|
// Check if something found
|
||||||
if (nNonceFound != -1)
|
if (nNonceFound != -1)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < sizeof(hash)/4; i++)
|
for (unsigned int i = 0; i < sizeof(hash)/4; i++)
|
||||||
((unsigned int*)&hash)[i] = ByteReverse(((unsigned int*)&hash)[i]);
|
((unsigned int*)&hash)[i] = ByteReverse(((unsigned int*)&hash)[i]);
|
||||||
|
|
||||||
if (hash <= hashTarget)
|
if (hash <= hashTarget)
|
||||||
|
|
12
src/main.h
12
src/main.h
|
@ -457,13 +457,13 @@ public:
|
||||||
{
|
{
|
||||||
if (vin.size() != old.vin.size())
|
if (vin.size() != old.vin.size())
|
||||||
return false;
|
return false;
|
||||||
for (int i = 0; i < vin.size(); i++)
|
for (unsigned int i = 0; i < vin.size(); i++)
|
||||||
if (vin[i].prevout != old.vin[i].prevout)
|
if (vin[i].prevout != old.vin[i].prevout)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool fNewer = false;
|
bool fNewer = false;
|
||||||
unsigned int nLowest = std::numeric_limits<unsigned int>::max();
|
unsigned int nLowest = std::numeric_limits<unsigned int>::max();
|
||||||
for (int i = 0; i < vin.size(); i++)
|
for (unsigned int i = 0; i < vin.size(); i++)
|
||||||
{
|
{
|
||||||
if (vin[i].nSequence != old.vin[i].nSequence)
|
if (vin[i].nSequence != old.vin[i].nSequence)
|
||||||
{
|
{
|
||||||
|
@ -637,9 +637,9 @@ public:
|
||||||
vin.size(),
|
vin.size(),
|
||||||
vout.size(),
|
vout.size(),
|
||||||
nLockTime);
|
nLockTime);
|
||||||
for (int i = 0; i < vin.size(); i++)
|
for (unsigned int i = 0; i < vin.size(); i++)
|
||||||
str += " " + vin[i].ToString() + "\n";
|
str += " " + vin[i].ToString() + "\n";
|
||||||
for (int i = 0; i < vout.size(); i++)
|
for (unsigned int i = 0; i < vout.size(); i++)
|
||||||
str += " " + vout[i].ToString() + "\n";
|
str += " " + vout[i].ToString() + "\n";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -1006,13 +1006,13 @@ public:
|
||||||
hashMerkleRoot.ToString().substr(0,10).c_str(),
|
hashMerkleRoot.ToString().substr(0,10).c_str(),
|
||||||
nTime, nBits, nNonce,
|
nTime, nBits, nNonce,
|
||||||
vtx.size());
|
vtx.size());
|
||||||
for (int i = 0; i < vtx.size(); i++)
|
for (unsigned int i = 0; i < vtx.size(); i++)
|
||||||
{
|
{
|
||||||
printf(" ");
|
printf(" ");
|
||||||
vtx[i].print();
|
vtx[i].print();
|
||||||
}
|
}
|
||||||
printf(" vMerkleTree: ");
|
printf(" vMerkleTree: ");
|
||||||
for (int i = 0; i < vMerkleTree.size(); i++)
|
for (unsigned int i = 0; i < vMerkleTree.size(); i++)
|
||||||
printf("%s ", vMerkleTree[i].ToString().substr(0,10).c_str());
|
printf("%s ", vMerkleTree[i].ToString().substr(0,10).c_str());
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
10
src/net.cpp
10
src/net.cpp
|
@ -162,14 +162,14 @@ bool GetMyExternalIP2(const CService& addrConnect, const char* pszGet, const cha
|
||||||
}
|
}
|
||||||
if (pszKeyword == NULL)
|
if (pszKeyword == NULL)
|
||||||
break;
|
break;
|
||||||
if (strLine.find(pszKeyword) != -1)
|
if (strLine.find(pszKeyword) != string::npos)
|
||||||
{
|
{
|
||||||
strLine = strLine.substr(strLine.find(pszKeyword) + strlen(pszKeyword));
|
strLine = strLine.substr(strLine.find(pszKeyword) + strlen(pszKeyword));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closesocket(hSocket);
|
closesocket(hSocket);
|
||||||
if (strLine.find("<") != -1)
|
if (strLine.find("<") != string::npos)
|
||||||
strLine = strLine.substr(0, strLine.find("<"));
|
strLine = strLine.substr(0, strLine.find("<"));
|
||||||
strLine = strLine.substr(strspn(strLine.c_str(), " \t\n\r"));
|
strLine = strLine.substr(strspn(strLine.c_str(), " \t\n\r"));
|
||||||
while (strLine.size() > 0 && isspace(strLine[strLine.size()-1]))
|
while (strLine.size() > 0 && isspace(strLine[strLine.size()-1]))
|
||||||
|
@ -624,7 +624,7 @@ void ThreadSocketHandler2(void* parg)
|
||||||
if (hSocketMax > -1)
|
if (hSocketMax > -1)
|
||||||
{
|
{
|
||||||
printf("socket select error %d\n", nErr);
|
printf("socket select error %d\n", nErr);
|
||||||
for (int i = 0; i <= hSocketMax; i++)
|
for (unsigned int i = 0; i <= hSocketMax; i++)
|
||||||
FD_SET(i, &fdsetRecv);
|
FD_SET(i, &fdsetRecv);
|
||||||
}
|
}
|
||||||
FD_ZERO(&fdsetSend);
|
FD_ZERO(&fdsetSend);
|
||||||
|
@ -1024,7 +1024,7 @@ void ThreadDNSAddressSeed2(void* parg)
|
||||||
{
|
{
|
||||||
printf("Loading addresses from DNS seeds (could take a while)\n");
|
printf("Loading addresses from DNS seeds (could take a while)\n");
|
||||||
|
|
||||||
for (int seed_idx = 0; seed_idx < ARRAYLEN(strDNSSeed); seed_idx++) {
|
for (unsigned int seed_idx = 0; seed_idx < ARRAYLEN(strDNSSeed); seed_idx++) {
|
||||||
vector<CNetAddr> vaddr;
|
vector<CNetAddr> vaddr;
|
||||||
vector<CAddress> vAdd;
|
vector<CAddress> vAdd;
|
||||||
if (LookupHost(strDNSSeed[seed_idx][1], vaddr))
|
if (LookupHost(strDNSSeed[seed_idx][1], vaddr))
|
||||||
|
@ -1238,7 +1238,7 @@ void ThreadOpenConnections2(void* parg)
|
||||||
if (addrman.size()==0 && (GetTime() - nStart > 60 || fTOR) && !fTestNet)
|
if (addrman.size()==0 && (GetTime() - nStart > 60 || fTOR) && !fTestNet)
|
||||||
{
|
{
|
||||||
std::vector<CAddress> vAdd;
|
std::vector<CAddress> vAdd;
|
||||||
for (int i = 0; i < ARRAYLEN(pnSeed); i++)
|
for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
|
||||||
{
|
{
|
||||||
// It'll only connect to one or two seed nodes because once it connects,
|
// It'll only connect to one or two seed nodes because once it connects,
|
||||||
// it'll get a pile of addresses with newer timestamps.
|
// it'll get a pile of addresses with newer timestamps.
|
||||||
|
|
|
@ -117,7 +117,7 @@ public:
|
||||||
int64 nLastRecv;
|
int64 nLastRecv;
|
||||||
int64 nLastSendEmpty;
|
int64 nLastSendEmpty;
|
||||||
int64 nTimeConnected;
|
int64 nTimeConnected;
|
||||||
unsigned int nHeaderStart;
|
int nHeaderStart;
|
||||||
unsigned int nMessageStart;
|
unsigned int nMessageStart;
|
||||||
CAddress addr;
|
CAddress addr;
|
||||||
int nVersion;
|
int nVersion;
|
||||||
|
@ -299,7 +299,7 @@ public:
|
||||||
|
|
||||||
void AbortMessage()
|
void AbortMessage()
|
||||||
{
|
{
|
||||||
if (nHeaderStart == -1)
|
if (nHeaderStart < 0)
|
||||||
return;
|
return;
|
||||||
vSend.resize(nHeaderStart);
|
vSend.resize(nHeaderStart);
|
||||||
nHeaderStart = -1;
|
nHeaderStart = -1;
|
||||||
|
@ -319,7 +319,7 @@ public:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nHeaderStart == -1)
|
if (nHeaderStart < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Set the size
|
// Set the size
|
||||||
|
@ -344,7 +344,7 @@ public:
|
||||||
|
|
||||||
void EndMessageAbortIfEmpty()
|
void EndMessageAbortIfEmpty()
|
||||||
{
|
{
|
||||||
if (nHeaderStart == -1)
|
if (nHeaderStart < 0)
|
||||||
return;
|
return;
|
||||||
int nSize = vSend.size() - nMessageStart;
|
int nSize = vSend.size() - nMessageStart;
|
||||||
if (nSize > 0)
|
if (nSize > 0)
|
||||||
|
|
|
@ -22,7 +22,7 @@ int nConnectTimeout = 5000;
|
||||||
|
|
||||||
static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };
|
static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };
|
||||||
|
|
||||||
bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, int nMaxSolutions, bool fAllowLookup)
|
bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup)
|
||||||
{
|
{
|
||||||
vIP.clear();
|
vIP.clear();
|
||||||
struct addrinfo aiHint;
|
struct addrinfo aiHint;
|
||||||
|
@ -77,7 +77,7 @@ bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, int nM
|
||||||
return (vIP.size() > 0);
|
return (vIP.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, int nMaxSolutions, bool fAllowLookup)
|
bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup)
|
||||||
{
|
{
|
||||||
if (pszName[0] == 0)
|
if (pszName[0] == 0)
|
||||||
return false;
|
return false;
|
||||||
|
@ -93,12 +93,12 @@ bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, int nMaxSolutio
|
||||||
return LookupIntern(pszHost, vIP, nMaxSolutions, fAllowLookup);
|
return LookupIntern(pszHost, vIP, nMaxSolutions, fAllowLookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LookupHostNumeric(const char *pszName, std::vector<CNetAddr>& vIP, int nMaxSolutions)
|
bool LookupHostNumeric(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions)
|
||||||
{
|
{
|
||||||
return LookupHost(pszName, vIP, nMaxSolutions, false);
|
return LookupHost(pszName, vIP, nMaxSolutions, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, int nMaxSolutions)
|
bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions)
|
||||||
{
|
{
|
||||||
if (pszName[0] == 0)
|
if (pszName[0] == 0)
|
||||||
return false;
|
return false;
|
||||||
|
@ -136,7 +136,7 @@ bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault,
|
||||||
if (!fRet)
|
if (!fRet)
|
||||||
return false;
|
return false;
|
||||||
vAddr.resize(vIP.size());
|
vAddr.resize(vIP.size());
|
||||||
for (int i = 0; i < vIP.size(); i++)
|
for (unsigned int i = 0; i < vIP.size(); i++)
|
||||||
vAddr[i] = CService(vIP[i], port);
|
vAddr[i] = CService(vIP[i], port);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,10 +134,10 @@ class CService : public CNetAddr
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, int nMaxSolutions = 0, bool fAllowLookup = true);
|
bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions = 0, bool fAllowLookup = true);
|
||||||
bool LookupHostNumeric(const char *pszName, std::vector<CNetAddr>& vIP, int nMaxSolutions = 0);
|
bool LookupHostNumeric(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions = 0);
|
||||||
bool Lookup(const char *pszName, CService& addr, int portDefault = 0, bool fAllowLookup = true);
|
bool Lookup(const char *pszName, CService& addr, int portDefault = 0, bool fAllowLookup = true);
|
||||||
bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault = 0, bool fAllowLookup = true, int nMaxSolutions = 0);
|
bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault = 0, bool fAllowLookup = true, unsigned int nMaxSolutions = 0);
|
||||||
bool LookupNumeric(const char *pszName, CService& addr, int portDefault = 0);
|
bool LookupNumeric(const char *pszName, CService& addr, int portDefault = 0);
|
||||||
bool ConnectSocket(const CService &addr, SOCKET& hSocketRet, int nTimeout = nConnectTimeout);
|
bool ConnectSocket(const CService &addr, SOCKET& hSocketRet, int nTimeout = nConnectTimeout);
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ CInv::CInv(int typeIn, const uint256& hashIn)
|
||||||
|
|
||||||
CInv::CInv(const std::string& strType, const uint256& hashIn)
|
CInv::CInv(const std::string& strType, const uint256& hashIn)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned int i;
|
||||||
for (i = 1; i < ARRAYLEN(ppszTypeName); i++)
|
for (i = 1; i < ARRAYLEN(ppszTypeName); i++)
|
||||||
{
|
{
|
||||||
if (strType == ppszTypeName[i])
|
if (strType == ppszTypeName[i])
|
||||||
|
|
|
@ -1138,7 +1138,7 @@ public:
|
||||||
void ReadVersion() { *this >> nVersion; }
|
void ReadVersion() { *this >> nVersion; }
|
||||||
void WriteVersion() { *this << nVersion; }
|
void WriteVersion() { *this << nVersion; }
|
||||||
|
|
||||||
CAutoFile& read(char* pch, int nSize)
|
CAutoFile& read(char* pch, size_t nSize)
|
||||||
{
|
{
|
||||||
if (!file)
|
if (!file)
|
||||||
throw std::ios_base::failure("CAutoFile::read : file handle is NULL");
|
throw std::ios_base::failure("CAutoFile::read : file handle is NULL");
|
||||||
|
@ -1147,7 +1147,7 @@ public:
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAutoFile& write(const char* pch, int nSize)
|
CAutoFile& write(const char* pch, size_t nSize)
|
||||||
{
|
{
|
||||||
if (!file)
|
if (!file)
|
||||||
throw std::ios_base::failure("CAutoFile::write : file handle is NULL");
|
throw std::ios_base::failure("CAutoFile::write : file handle is NULL");
|
||||||
|
|
|
@ -287,7 +287,7 @@ public:
|
||||||
std::string GetHex() const
|
std::string GetHex() const
|
||||||
{
|
{
|
||||||
char psz[sizeof(pn)*2 + 1];
|
char psz[sizeof(pn)*2 + 1];
|
||||||
for (int i = 0; i < sizeof(pn); i++)
|
for (unsigned int i = 0; i < sizeof(pn); i++)
|
||||||
sprintf(psz + i*2, "%02x", ((unsigned char*)pn)[sizeof(pn) - i - 1]);
|
sprintf(psz + i*2, "%02x", ((unsigned char*)pn)[sizeof(pn) - i - 1]);
|
||||||
return std::string(psz, psz + sizeof(pn)*2);
|
return std::string(psz, psz + sizeof(pn)*2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -615,7 +615,7 @@ void CWalletTx::AddSupportingTransactions(CTxDB& txdb)
|
||||||
LOCK(pwallet->cs_wallet);
|
LOCK(pwallet->cs_wallet);
|
||||||
map<uint256, const CMerkleTx*> mapWalletPrev;
|
map<uint256, const CMerkleTx*> mapWalletPrev;
|
||||||
set<uint256> setAlreadyDone;
|
set<uint256> setAlreadyDone;
|
||||||
for (int i = 0; i < vWorkQueue.size(); i++)
|
for (unsigned int i = 0; i < vWorkQueue.size(); i++)
|
||||||
{
|
{
|
||||||
uint256 hash = vWorkQueue[i];
|
uint256 hash = vWorkQueue[i];
|
||||||
if (setAlreadyDone.count(hash))
|
if (setAlreadyDone.count(hash))
|
||||||
|
@ -723,7 +723,7 @@ void CWallet::ReacceptWalletTransactions()
|
||||||
printf("ERROR: ReacceptWalletTransactions() : txindex.vSpent.size() %d != wtx.vout.size() %d\n", txindex.vSpent.size(), wtx.vout.size());
|
printf("ERROR: ReacceptWalletTransactions() : txindex.vSpent.size() %d != wtx.vout.size() %d\n", txindex.vSpent.size(), wtx.vout.size());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < txindex.vSpent.size(); i++)
|
for (unsigned int i = 0; i < txindex.vSpent.size(); i++)
|
||||||
{
|
{
|
||||||
if (wtx.IsSpent(i))
|
if (wtx.IsSpent(i))
|
||||||
continue;
|
continue;
|
||||||
|
@ -902,7 +902,7 @@ bool CWallet::SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfThe
|
||||||
if (nDepth < (pcoin->IsFromMe() ? nConfMine : nConfTheirs))
|
if (nDepth < (pcoin->IsFromMe() ? nConfMine : nConfTheirs))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (int i = 0; i < pcoin->vout.size(); i++)
|
for (unsigned int i = 0; i < pcoin->vout.size(); i++)
|
||||||
{
|
{
|
||||||
if (pcoin->IsSpent(i) || !IsMine(pcoin->vout[i]))
|
if (pcoin->IsSpent(i) || !IsMine(pcoin->vout[i]))
|
||||||
continue;
|
continue;
|
||||||
|
@ -935,7 +935,7 @@ bool CWallet::SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfThe
|
||||||
|
|
||||||
if (nTotalLower == nTargetValue || nTotalLower == nTargetValue + CENT)
|
if (nTotalLower == nTargetValue || nTotalLower == nTargetValue + CENT)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < vValue.size(); ++i)
|
for (unsigned int i = 0; i < vValue.size(); ++i)
|
||||||
{
|
{
|
||||||
setCoinsRet.insert(vValue[i].second);
|
setCoinsRet.insert(vValue[i].second);
|
||||||
nValueRet += vValue[i].first;
|
nValueRet += vValue[i].first;
|
||||||
|
@ -968,7 +968,7 @@ bool CWallet::SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfThe
|
||||||
bool fReachedTarget = false;
|
bool fReachedTarget = false;
|
||||||
for (int nPass = 0; nPass < 2 && !fReachedTarget; nPass++)
|
for (int nPass = 0; nPass < 2 && !fReachedTarget; nPass++)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < vValue.size(); i++)
|
for (unsigned int i = 0; i < vValue.size(); i++)
|
||||||
{
|
{
|
||||||
if (nPass == 0 ? rand() % 2 : !vfIncluded[i])
|
if (nPass == 0 ? rand() % 2 : !vfIncluded[i])
|
||||||
{
|
{
|
||||||
|
@ -997,7 +997,7 @@ bool CWallet::SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfThe
|
||||||
nValueRet += coinLowestLarger.first;
|
nValueRet += coinLowestLarger.first;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int i = 0; i < vValue.size(); i++)
|
for (unsigned int i = 0; i < vValue.size(); i++)
|
||||||
if (vfBest[i])
|
if (vfBest[i])
|
||||||
{
|
{
|
||||||
setCoinsRet.insert(vValue[i].second);
|
setCoinsRet.insert(vValue[i].second);
|
||||||
|
@ -1006,7 +1006,7 @@ bool CWallet::SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfThe
|
||||||
|
|
||||||
//// debug print
|
//// debug print
|
||||||
printf("SelectCoins() best subset: ");
|
printf("SelectCoins() best subset: ");
|
||||||
for (int i = 0; i < vValue.size(); i++)
|
for (unsigned int i = 0; i < vValue.size(); i++)
|
||||||
if (vfBest[i])
|
if (vfBest[i])
|
||||||
printf("%s ", FormatMoney(vValue[i].first).c_str());
|
printf("%s ", FormatMoney(vValue[i].first).c_str());
|
||||||
printf("total %s\n", FormatMoney(nBest).c_str());
|
printf("total %s\n", FormatMoney(nBest).c_str());
|
||||||
|
|
|
@ -402,7 +402,7 @@ public:
|
||||||
bool UpdateSpent(const std::vector<char>& vfNewSpent)
|
bool UpdateSpent(const std::vector<char>& vfNewSpent)
|
||||||
{
|
{
|
||||||
bool fReturn = false;
|
bool fReturn = false;
|
||||||
for (int i=0; i < vfNewSpent.size(); i++)
|
for (unsigned int i = 0; i < vfNewSpent.size(); i++)
|
||||||
{
|
{
|
||||||
if (i == vfSpent.size())
|
if (i == vfSpent.size())
|
||||||
break;
|
break;
|
||||||
|
@ -488,7 +488,7 @@ public:
|
||||||
return nAvailableCreditCached;
|
return nAvailableCreditCached;
|
||||||
|
|
||||||
int64 nCredit = 0;
|
int64 nCredit = 0;
|
||||||
for (int i = 0; i < vout.size(); i++)
|
for (unsigned int i = 0; i < vout.size(); i++)
|
||||||
{
|
{
|
||||||
if (!IsSpent(i))
|
if (!IsSpent(i))
|
||||||
{
|
{
|
||||||
|
@ -541,7 +541,7 @@ public:
|
||||||
std::vector<const CMerkleTx*> vWorkQueue;
|
std::vector<const CMerkleTx*> vWorkQueue;
|
||||||
vWorkQueue.reserve(vtxPrev.size()+1);
|
vWorkQueue.reserve(vtxPrev.size()+1);
|
||||||
vWorkQueue.push_back(this);
|
vWorkQueue.push_back(this);
|
||||||
for (int i = 0; i < vWorkQueue.size(); i++)
|
for (unsigned int i = 0; i < vWorkQueue.size(); i++)
|
||||||
{
|
{
|
||||||
const CMerkleTx* ptx = vWorkQueue[i];
|
const CMerkleTx* ptx = vWorkQueue[i];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue