Do not shadow variables
This commit is contained in:
parent
2f71490d21
commit
4731cab8fb
15 changed files with 89 additions and 89 deletions
|
@ -280,8 +280,8 @@ void CRollingBloomFilter::insert(const std::vector<unsigned char>& vKey)
|
||||||
|
|
||||||
void CRollingBloomFilter::insert(const uint256& hash)
|
void CRollingBloomFilter::insert(const uint256& hash)
|
||||||
{
|
{
|
||||||
vector<unsigned char> data(hash.begin(), hash.end());
|
vector<unsigned char> vData(hash.begin(), hash.end());
|
||||||
insert(data);
|
insert(vData);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CRollingBloomFilter::contains(const std::vector<unsigned char>& vKey) const
|
bool CRollingBloomFilter::contains(const std::vector<unsigned char>& vKey) const
|
||||||
|
@ -300,8 +300,8 @@ bool CRollingBloomFilter::contains(const std::vector<unsigned char>& vKey) const
|
||||||
|
|
||||||
bool CRollingBloomFilter::contains(const uint256& hash) const
|
bool CRollingBloomFilter::contains(const uint256& hash) const
|
||||||
{
|
{
|
||||||
vector<unsigned char> data(hash.begin(), hash.end());
|
vector<unsigned char> vData(hash.begin(), hash.end());
|
||||||
return contains(data);
|
return contains(vData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRollingBloomFilter::reset()
|
void CRollingBloomFilter::reset()
|
||||||
|
|
|
@ -243,12 +243,12 @@ bool CKey::Derive(CKey& keyChild, ChainCode &ccChild, unsigned int nChild, const
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CExtKey::Derive(CExtKey &out, unsigned int nChild) const {
|
bool CExtKey::Derive(CExtKey &out, unsigned int _nChild) const {
|
||||||
out.nDepth = nDepth + 1;
|
out.nDepth = nDepth + 1;
|
||||||
CKeyID id = key.GetPubKey().GetID();
|
CKeyID id = key.GetPubKey().GetID();
|
||||||
memcpy(&out.vchFingerprint[0], &id, 4);
|
memcpy(&out.vchFingerprint[0], &id, 4);
|
||||||
out.nChild = nChild;
|
out.nChild = _nChild;
|
||||||
return key.Derive(out.key, out.chaincode, nChild, chaincode);
|
return key.Derive(out.key, out.chaincode, _nChild, chaincode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CExtKey::SetMaster(const unsigned char *seed, unsigned int nSeedLen) {
|
void CExtKey::SetMaster(const unsigned char *seed, unsigned int nSeedLen) {
|
||||||
|
|
28
src/main.cpp
28
src/main.cpp
|
@ -1185,9 +1185,9 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
|
||||||
bool fReplacementOptOut = true;
|
bool fReplacementOptOut = true;
|
||||||
if (fEnableReplacement)
|
if (fEnableReplacement)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const CTxIn &txin, ptxConflicting->vin)
|
BOOST_FOREACH(const CTxIn &_txin, ptxConflicting->vin)
|
||||||
{
|
{
|
||||||
if (txin.nSequence < std::numeric_limits<unsigned int>::max()-1)
|
if (_txin.nSequence < std::numeric_limits<unsigned int>::max()-1)
|
||||||
{
|
{
|
||||||
fReplacementOptOut = false;
|
fReplacementOptOut = false;
|
||||||
break;
|
break;
|
||||||
|
@ -2499,14 +2499,14 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||||
if (pindex->GetUndoPos().IsNull() || !pindex->IsValid(BLOCK_VALID_SCRIPTS))
|
if (pindex->GetUndoPos().IsNull() || !pindex->IsValid(BLOCK_VALID_SCRIPTS))
|
||||||
{
|
{
|
||||||
if (pindex->GetUndoPos().IsNull()) {
|
if (pindex->GetUndoPos().IsNull()) {
|
||||||
CDiskBlockPos pos;
|
CDiskBlockPos _pos;
|
||||||
if (!FindUndoPos(state, pindex->nFile, pos, ::GetSerializeSize(blockundo, SER_DISK, CLIENT_VERSION) + 40))
|
if (!FindUndoPos(state, pindex->nFile, _pos, ::GetSerializeSize(blockundo, SER_DISK, CLIENT_VERSION) + 40))
|
||||||
return error("ConnectBlock(): FindUndoPos failed");
|
return error("ConnectBlock(): FindUndoPos failed");
|
||||||
if (!UndoWriteToDisk(blockundo, pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart()))
|
if (!UndoWriteToDisk(blockundo, _pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart()))
|
||||||
return AbortNode(state, "Failed to write undo data");
|
return AbortNode(state, "Failed to write undo data");
|
||||||
|
|
||||||
// update nUndoPos in block index
|
// update nUndoPos in block index
|
||||||
pindex->nUndoPos = pos.nPos;
|
pindex->nUndoPos = _pos.nPos;
|
||||||
pindex->nStatus |= BLOCK_HAVE_UNDO;
|
pindex->nStatus |= BLOCK_HAVE_UNDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3819,10 +3819,10 @@ void PruneOneBlockFile(const int fileNumber)
|
||||||
// mapBlocksUnlinked or setBlockIndexCandidates.
|
// mapBlocksUnlinked or setBlockIndexCandidates.
|
||||||
std::pair<std::multimap<CBlockIndex*, CBlockIndex*>::iterator, std::multimap<CBlockIndex*, CBlockIndex*>::iterator> range = mapBlocksUnlinked.equal_range(pindex->pprev);
|
std::pair<std::multimap<CBlockIndex*, CBlockIndex*>::iterator, std::multimap<CBlockIndex*, CBlockIndex*>::iterator> range = mapBlocksUnlinked.equal_range(pindex->pprev);
|
||||||
while (range.first != range.second) {
|
while (range.first != range.second) {
|
||||||
std::multimap<CBlockIndex *, CBlockIndex *>::iterator it = range.first;
|
std::multimap<CBlockIndex *, CBlockIndex *>::iterator _it = range.first;
|
||||||
range.first++;
|
range.first++;
|
||||||
if (it->second == pindex) {
|
if (_it->second == pindex) {
|
||||||
mapBlocksUnlinked.erase(it);
|
mapBlocksUnlinked.erase(_it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5550,9 +5550,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
}
|
}
|
||||||
if (!fRejectedParents) {
|
if (!fRejectedParents) {
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
|
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
|
||||||
CInv inv(MSG_TX, txin.prevout.hash);
|
CInv _inv(MSG_TX, txin.prevout.hash);
|
||||||
pfrom->AddInventoryKnown(inv);
|
pfrom->AddInventoryKnown(_inv);
|
||||||
if (!AlreadyHave(inv)) pfrom->AskFor(inv);
|
if (!AlreadyHave(_inv)) pfrom->AskFor(_inv);
|
||||||
}
|
}
|
||||||
AddOrphanTx(tx, pfrom->GetId());
|
AddOrphanTx(tx, pfrom->GetId());
|
||||||
|
|
||||||
|
@ -6317,9 +6317,9 @@ class CompareInvMempoolOrder
|
||||||
{
|
{
|
||||||
CTxMemPool *mp;
|
CTxMemPool *mp;
|
||||||
public:
|
public:
|
||||||
CompareInvMempoolOrder(CTxMemPool *mempool)
|
CompareInvMempoolOrder(CTxMemPool *_mempool)
|
||||||
{
|
{
|
||||||
mp = mempool;
|
mp = _mempool;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator()(std::set<uint256>::iterator a, std::set<uint256>::iterator b)
|
bool operator()(std::set<uint256>::iterator a, std::set<uint256>::iterator b)
|
||||||
|
|
|
@ -264,12 +264,12 @@ void CExtPubKey::Decode(const unsigned char code[BIP32_EXTKEY_SIZE]) {
|
||||||
pubkey.Set(code+41, code+BIP32_EXTKEY_SIZE);
|
pubkey.Set(code+41, code+BIP32_EXTKEY_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CExtPubKey::Derive(CExtPubKey &out, unsigned int nChild) const {
|
bool CExtPubKey::Derive(CExtPubKey &out, unsigned int _nChild) const {
|
||||||
out.nDepth = nDepth + 1;
|
out.nDepth = nDepth + 1;
|
||||||
CKeyID id = pubkey.GetID();
|
CKeyID id = pubkey.GetID();
|
||||||
memcpy(&out.vchFingerprint[0], &id, 4);
|
memcpy(&out.vchFingerprint[0], &id, 4);
|
||||||
out.nChild = nChild;
|
out.nChild = _nChild;
|
||||||
return pubkey.Derive(out.pubkey, out.chaincode, nChild, chaincode);
|
return pubkey.Derive(out.pubkey, out.chaincode, _nChild, chaincode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool CPubKey::CheckLowS(const std::vector<unsigned char>& vchSig) {
|
/* static */ bool CPubKey::CheckLowS(const std::vector<unsigned char>& vchSig) {
|
||||||
|
|
|
@ -88,9 +88,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Construct a public key from a byte vector.
|
//! Construct a public key from a byte vector.
|
||||||
CPubKey(const std::vector<unsigned char>& vch)
|
CPubKey(const std::vector<unsigned char>& _vch)
|
||||||
{
|
{
|
||||||
Set(vch.begin(), vch.end());
|
Set(_vch.begin(), _vch.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Simple read-only vector-like interface to the pubkey data.
|
//! Simple read-only vector-like interface to the pubkey data.
|
||||||
|
|
|
@ -13,9 +13,9 @@ class reverse_lock
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit reverse_lock(Lock& lock) : lock(lock) {
|
explicit reverse_lock(Lock& _lock) : lock(_lock) {
|
||||||
lock.unlock();
|
_lock.unlock();
|
||||||
lock.swap(templock);
|
_lock.swap(templock);
|
||||||
}
|
}
|
||||||
|
|
||||||
~reverse_lock() {
|
~reverse_lock() {
|
||||||
|
|
|
@ -497,10 +497,10 @@ UniValue getmempoolancestors(const UniValue& params, bool fHelp)
|
||||||
UniValue o(UniValue::VOBJ);
|
UniValue o(UniValue::VOBJ);
|
||||||
BOOST_FOREACH(CTxMemPool::txiter ancestorIt, setAncestors) {
|
BOOST_FOREACH(CTxMemPool::txiter ancestorIt, setAncestors) {
|
||||||
const CTxMemPoolEntry &e = *ancestorIt;
|
const CTxMemPoolEntry &e = *ancestorIt;
|
||||||
const uint256& hash = e.GetTx().GetHash();
|
const uint256& _hash = e.GetTx().GetHash();
|
||||||
UniValue info(UniValue::VOBJ);
|
UniValue info(UniValue::VOBJ);
|
||||||
entryToJSON(info, e);
|
entryToJSON(info, e);
|
||||||
o.push_back(Pair(hash.ToString(), info));
|
o.push_back(Pair(_hash.ToString(), info));
|
||||||
}
|
}
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
@ -561,10 +561,10 @@ UniValue getmempooldescendants(const UniValue& params, bool fHelp)
|
||||||
UniValue o(UniValue::VOBJ);
|
UniValue o(UniValue::VOBJ);
|
||||||
BOOST_FOREACH(CTxMemPool::txiter descendantIt, setDescendants) {
|
BOOST_FOREACH(CTxMemPool::txiter descendantIt, setDescendants) {
|
||||||
const CTxMemPoolEntry &e = *descendantIt;
|
const CTxMemPoolEntry &e = *descendantIt;
|
||||||
const uint256& hash = e.GetTx().GetHash();
|
const uint256& _hash = e.GetTx().GetHash();
|
||||||
UniValue info(UniValue::VOBJ);
|
UniValue info(UniValue::VOBJ);
|
||||||
entryToJSON(info, e);
|
entryToJSON(info, e);
|
||||||
o.push_back(Pair(hash.ToString(), info));
|
o.push_back(Pair(_hash.ToString(), info));
|
||||||
}
|
}
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
|
@ -607,8 +607,8 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||||
|
|
||||||
UniValue aRules(UniValue::VARR);
|
UniValue aRules(UniValue::VARR);
|
||||||
UniValue vbavailable(UniValue::VOBJ);
|
UniValue vbavailable(UniValue::VOBJ);
|
||||||
for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++i) {
|
for (int j = 0; j < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++j) {
|
||||||
Consensus::DeploymentPos pos = Consensus::DeploymentPos(i);
|
Consensus::DeploymentPos pos = Consensus::DeploymentPos(j);
|
||||||
ThresholdState state = VersionBitsState(pindexPrev, consensusParams, pos, versionbitscache);
|
ThresholdState state = VersionBitsState(pindexPrev, consensusParams, pos, versionbitscache);
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case THRESHOLD_DEFINED:
|
case THRESHOLD_DEFINED:
|
||||||
|
|
|
@ -28,11 +28,11 @@ template <class Locker>
|
||||||
class LockedPageManagerBase
|
class LockedPageManagerBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LockedPageManagerBase(size_t page_size) : page_size(page_size)
|
LockedPageManagerBase(size_t _page_size) : page_size(_page_size)
|
||||||
{
|
{
|
||||||
// Determine bitmask for extracting page from address
|
// Determine bitmask for extracting page from address
|
||||||
assert(!(page_size & (page_size - 1))); // size must be power of two
|
assert(!(_page_size & (_page_size - 1))); // size must be power of two
|
||||||
page_mask = ~(page_size - 1);
|
page_mask = ~(_page_size - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
~LockedPageManagerBase()
|
~LockedPageManagerBase()
|
||||||
|
|
|
@ -133,13 +133,13 @@ void TestAES128CBC(const std::string &hexkey, const std::string &hexiv, bool pad
|
||||||
{
|
{
|
||||||
std::vector<unsigned char> sub(i, in.end());
|
std::vector<unsigned char> sub(i, in.end());
|
||||||
std::vector<unsigned char> subout(sub.size() + AES_BLOCKSIZE);
|
std::vector<unsigned char> subout(sub.size() + AES_BLOCKSIZE);
|
||||||
int size = enc.Encrypt(&sub[0], sub.size(), &subout[0]);
|
int _size = enc.Encrypt(&sub[0], sub.size(), &subout[0]);
|
||||||
if (size != 0)
|
if (_size != 0)
|
||||||
{
|
{
|
||||||
subout.resize(size);
|
subout.resize(_size);
|
||||||
std::vector<unsigned char> subdecrypted(subout.size());
|
std::vector<unsigned char> subdecrypted(subout.size());
|
||||||
size = dec.Decrypt(&subout[0], subout.size(), &subdecrypted[0]);
|
_size = dec.Decrypt(&subout[0], subout.size(), &subdecrypted[0]);
|
||||||
subdecrypted.resize(size);
|
subdecrypted.resize(_size);
|
||||||
BOOST_CHECK(decrypted.size() == in.size());
|
BOOST_CHECK(decrypted.size() == in.size());
|
||||||
BOOST_CHECK_MESSAGE(subdecrypted == sub, HexStr(subdecrypted) + std::string(" != ") + HexStr(sub));
|
BOOST_CHECK_MESSAGE(subdecrypted == sub, HexStr(subdecrypted) + std::string(" != ") + HexStr(sub));
|
||||||
}
|
}
|
||||||
|
@ -174,13 +174,13 @@ void TestAES256CBC(const std::string &hexkey, const std::string &hexiv, bool pad
|
||||||
{
|
{
|
||||||
std::vector<unsigned char> sub(i, in.end());
|
std::vector<unsigned char> sub(i, in.end());
|
||||||
std::vector<unsigned char> subout(sub.size() + AES_BLOCKSIZE);
|
std::vector<unsigned char> subout(sub.size() + AES_BLOCKSIZE);
|
||||||
int size = enc.Encrypt(&sub[0], sub.size(), &subout[0]);
|
int _size = enc.Encrypt(&sub[0], sub.size(), &subout[0]);
|
||||||
if (size != 0)
|
if (_size != 0)
|
||||||
{
|
{
|
||||||
subout.resize(size);
|
subout.resize(_size);
|
||||||
std::vector<unsigned char> subdecrypted(subout.size());
|
std::vector<unsigned char> subdecrypted(subout.size());
|
||||||
size = dec.Decrypt(&subout[0], subout.size(), &subdecrypted[0]);
|
_size = dec.Decrypt(&subout[0], subout.size(), &subdecrypted[0]);
|
||||||
subdecrypted.resize(size);
|
subdecrypted.resize(_size);
|
||||||
BOOST_CHECK(decrypted.size() == in.size());
|
BOOST_CHECK(decrypted.size() == in.size());
|
||||||
BOOST_CHECK_MESSAGE(subdecrypted == sub, HexStr(subdecrypted) + std::string(" != ") + HexStr(sub));
|
BOOST_CHECK_MESSAGE(subdecrypted == sub, HexStr(subdecrypted) + std::string(" != ") + HexStr(sub));
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,11 +62,11 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CDataStream AddrmanToStream(CAddrManSerializationMock& addrman)
|
CDataStream AddrmanToStream(CAddrManSerializationMock& _addrman)
|
||||||
{
|
{
|
||||||
CDataStream ssPeersIn(SER_DISK, CLIENT_VERSION);
|
CDataStream ssPeersIn(SER_DISK, CLIENT_VERSION);
|
||||||
ssPeersIn << FLATDATA(Params().MessageStart());
|
ssPeersIn << FLATDATA(Params().MessageStart());
|
||||||
ssPeersIn << addrman;
|
ssPeersIn << _addrman;
|
||||||
std::string str = ssPeersIn.str();
|
std::string str = ssPeersIn.str();
|
||||||
vector<unsigned char> vchData(str.begin(), str.end());
|
vector<unsigned char> vchData(str.begin(), str.end());
|
||||||
return CDataStream(vchData, SER_DISK, CLIENT_VERSION);
|
return CDataStream(vchData, SER_DISK, CLIENT_VERSION);
|
||||||
|
|
|
@ -323,10 +323,10 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
TestBuilder& Add(const CScript& script)
|
TestBuilder& Add(const CScript& _script)
|
||||||
{
|
{
|
||||||
DoPush();
|
DoPush();
|
||||||
spendTx.vin[0].scriptSig += script;
|
spendTx.vin[0].scriptSig += _script;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,8 +343,8 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
TestBuilder& Push(const CScript& script) {
|
TestBuilder& Push(const CScript& _script) {
|
||||||
DoPush(std::vector<unsigned char>(script.begin(), script.end()));
|
DoPush(std::vector<unsigned char>(_script.begin(), _script.end()));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,8 +122,8 @@ private:
|
||||||
static void eventcb(struct bufferevent *bev, short what, void *ctx);
|
static void eventcb(struct bufferevent *bev, short what, void *ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
TorControlConnection::TorControlConnection(struct event_base *base):
|
TorControlConnection::TorControlConnection(struct event_base *_base):
|
||||||
base(base), b_conn(0)
|
base(_base), b_conn(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ void TorControlConnection::eventcb(struct bufferevent *bev, short what, void *ct
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TorControlConnection::Connect(const std::string &target, const ConnectionCB& connected, const ConnectionCB& disconnected)
|
bool TorControlConnection::Connect(const std::string &target, const ConnectionCB& _connected, const ConnectionCB& _disconnected)
|
||||||
{
|
{
|
||||||
if (b_conn)
|
if (b_conn)
|
||||||
Disconnect();
|
Disconnect();
|
||||||
|
@ -213,8 +213,8 @@ bool TorControlConnection::Connect(const std::string &target, const ConnectionCB
|
||||||
return false;
|
return false;
|
||||||
bufferevent_setcb(b_conn, TorControlConnection::readcb, NULL, TorControlConnection::eventcb, this);
|
bufferevent_setcb(b_conn, TorControlConnection::readcb, NULL, TorControlConnection::eventcb, this);
|
||||||
bufferevent_enable(b_conn, EV_READ|EV_WRITE);
|
bufferevent_enable(b_conn, EV_READ|EV_WRITE);
|
||||||
this->connected = connected;
|
this->connected = _connected;
|
||||||
this->disconnected = disconnected;
|
this->disconnected = _disconnected;
|
||||||
|
|
||||||
// Finally, connect to target
|
// Finally, connect to target
|
||||||
if (bufferevent_socket_connect(b_conn, (struct sockaddr*)&connect_to_addr, connect_to_addrlen) < 0) {
|
if (bufferevent_socket_connect(b_conn, (struct sockaddr*)&connect_to_addr, connect_to_addrlen) < 0) {
|
||||||
|
@ -394,18 +394,18 @@ private:
|
||||||
static void reconnect_cb(evutil_socket_t fd, short what, void *arg);
|
static void reconnect_cb(evutil_socket_t fd, short what, void *arg);
|
||||||
};
|
};
|
||||||
|
|
||||||
TorController::TorController(struct event_base* baseIn, const std::string& target):
|
TorController::TorController(struct event_base* _base, const std::string& _target):
|
||||||
base(baseIn),
|
base(_base),
|
||||||
target(target), conn(base), reconnect(true), reconnect_ev(0),
|
target(_target), conn(base), reconnect(true), reconnect_ev(0),
|
||||||
reconnect_timeout(RECONNECT_TIMEOUT_START)
|
reconnect_timeout(RECONNECT_TIMEOUT_START)
|
||||||
{
|
{
|
||||||
reconnect_ev = event_new(base, -1, 0, reconnect_cb, this);
|
reconnect_ev = event_new(base, -1, 0, reconnect_cb, this);
|
||||||
if (!reconnect_ev)
|
if (!reconnect_ev)
|
||||||
LogPrintf("tor: Failed to create event for reconnection: out of memory?\n");
|
LogPrintf("tor: Failed to create event for reconnection: out of memory?\n");
|
||||||
// Start connection attempts immediately
|
// Start connection attempts immediately
|
||||||
if (!conn.Connect(target, boost::bind(&TorController::connected_cb, this, _1),
|
if (!conn.Connect(_target, boost::bind(&TorController::connected_cb, this, _1),
|
||||||
boost::bind(&TorController::disconnected_cb, this, _1) )) {
|
boost::bind(&TorController::disconnected_cb, this, _1) )) {
|
||||||
LogPrintf("tor: Initiating connection to Tor control port %s failed\n", target);
|
LogPrintf("tor: Initiating connection to Tor control port %s failed\n", _target);
|
||||||
}
|
}
|
||||||
// Read service private key if cached
|
// Read service private key if cached
|
||||||
std::pair<bool,std::string> pkf = ReadBinaryFile(GetPrivateKeyFile());
|
std::pair<bool,std::string> pkf = ReadBinaryFile(GetPrivateKeyFile());
|
||||||
|
@ -426,7 +426,7 @@ TorController::~TorController()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorController::add_onion_cb(TorControlConnection& conn, const TorControlReply& reply)
|
void TorController::add_onion_cb(TorControlConnection& _conn, const TorControlReply& reply)
|
||||||
{
|
{
|
||||||
if (reply.code == 250) {
|
if (reply.code == 250) {
|
||||||
LogPrint("tor", "tor: ADD_ONION successful\n");
|
LogPrint("tor", "tor: ADD_ONION successful\n");
|
||||||
|
@ -454,7 +454,7 @@ void TorController::add_onion_cb(TorControlConnection& conn, const TorControlRep
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorController::auth_cb(TorControlConnection& conn, const TorControlReply& reply)
|
void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply& reply)
|
||||||
{
|
{
|
||||||
if (reply.code == 250) {
|
if (reply.code == 250) {
|
||||||
LogPrint("tor", "tor: Authentication successful\n");
|
LogPrint("tor", "tor: Authentication successful\n");
|
||||||
|
@ -474,7 +474,7 @@ void TorController::auth_cb(TorControlConnection& conn, const TorControlReply& r
|
||||||
// Request hidden service, redirect port.
|
// Request hidden service, redirect port.
|
||||||
// Note that the 'virtual' port doesn't have to be the same as our internal port, but this is just a convenient
|
// Note that the 'virtual' port doesn't have to be the same as our internal port, but this is just a convenient
|
||||||
// choice. TODO; refactor the shutdown sequence some day.
|
// choice. TODO; refactor the shutdown sequence some day.
|
||||||
conn.Command(strprintf("ADD_ONION %s Port=%i,127.0.0.1:%i", private_key, GetListenPort(), GetListenPort()),
|
_conn.Command(strprintf("ADD_ONION %s Port=%i,127.0.0.1:%i", private_key, GetListenPort(), GetListenPort()),
|
||||||
boost::bind(&TorController::add_onion_cb, this, _1, _2));
|
boost::bind(&TorController::add_onion_cb, this, _1, _2));
|
||||||
} else {
|
} else {
|
||||||
LogPrintf("tor: Authentication failed\n");
|
LogPrintf("tor: Authentication failed\n");
|
||||||
|
@ -508,7 +508,7 @@ static std::vector<uint8_t> ComputeResponse(const std::string &key, const std::v
|
||||||
return computedHash;
|
return computedHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorController::authchallenge_cb(TorControlConnection& conn, const TorControlReply& reply)
|
void TorController::authchallenge_cb(TorControlConnection& _conn, const TorControlReply& reply)
|
||||||
{
|
{
|
||||||
if (reply.code == 250) {
|
if (reply.code == 250) {
|
||||||
LogPrint("tor", "tor: SAFECOOKIE authentication challenge successful\n");
|
LogPrint("tor", "tor: SAFECOOKIE authentication challenge successful\n");
|
||||||
|
@ -530,7 +530,7 @@ void TorController::authchallenge_cb(TorControlConnection& conn, const TorContro
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> computedClientHash = ComputeResponse(TOR_SAFE_CLIENTKEY, cookie, clientNonce, serverNonce);
|
std::vector<uint8_t> computedClientHash = ComputeResponse(TOR_SAFE_CLIENTKEY, cookie, clientNonce, serverNonce);
|
||||||
conn.Command("AUTHENTICATE " + HexStr(computedClientHash), boost::bind(&TorController::auth_cb, this, _1, _2));
|
_conn.Command("AUTHENTICATE " + HexStr(computedClientHash), boost::bind(&TorController::auth_cb, this, _1, _2));
|
||||||
} else {
|
} else {
|
||||||
LogPrintf("tor: Invalid reply to AUTHCHALLENGE\n");
|
LogPrintf("tor: Invalid reply to AUTHCHALLENGE\n");
|
||||||
}
|
}
|
||||||
|
@ -539,7 +539,7 @@ void TorController::authchallenge_cb(TorControlConnection& conn, const TorContro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorController::protocolinfo_cb(TorControlConnection& conn, const TorControlReply& reply)
|
void TorController::protocolinfo_cb(TorControlConnection& _conn, const TorControlReply& reply)
|
||||||
{
|
{
|
||||||
if (reply.code == 250) {
|
if (reply.code == 250) {
|
||||||
std::set<std::string> methods;
|
std::set<std::string> methods;
|
||||||
|
@ -579,23 +579,23 @@ void TorController::protocolinfo_cb(TorControlConnection& conn, const TorControl
|
||||||
if (methods.count("HASHEDPASSWORD")) {
|
if (methods.count("HASHEDPASSWORD")) {
|
||||||
LogPrint("tor", "tor: Using HASHEDPASSWORD authentication\n");
|
LogPrint("tor", "tor: Using HASHEDPASSWORD authentication\n");
|
||||||
boost::replace_all(torpassword, "\"", "\\\"");
|
boost::replace_all(torpassword, "\"", "\\\"");
|
||||||
conn.Command("AUTHENTICATE \"" + torpassword + "\"", boost::bind(&TorController::auth_cb, this, _1, _2));
|
_conn.Command("AUTHENTICATE \"" + torpassword + "\"", boost::bind(&TorController::auth_cb, this, _1, _2));
|
||||||
} else {
|
} else {
|
||||||
LogPrintf("tor: Password provided with -torpassword, but HASHEDPASSWORD authentication is not available\n");
|
LogPrintf("tor: Password provided with -torpassword, but HASHEDPASSWORD authentication is not available\n");
|
||||||
}
|
}
|
||||||
} else if (methods.count("NULL")) {
|
} else if (methods.count("NULL")) {
|
||||||
LogPrint("tor", "tor: Using NULL authentication\n");
|
LogPrint("tor", "tor: Using NULL authentication\n");
|
||||||
conn.Command("AUTHENTICATE", boost::bind(&TorController::auth_cb, this, _1, _2));
|
_conn.Command("AUTHENTICATE", boost::bind(&TorController::auth_cb, this, _1, _2));
|
||||||
} else if (methods.count("SAFECOOKIE")) {
|
} else if (methods.count("SAFECOOKIE")) {
|
||||||
// Cookie: hexdump -e '32/1 "%02x""\n"' ~/.tor/control_auth_cookie
|
// Cookie: hexdump -e '32/1 "%02x""\n"' ~/.tor/control_auth_cookie
|
||||||
LogPrint("tor", "tor: Using SAFECOOKIE authentication, reading cookie authentication from %s\n", cookiefile);
|
LogPrint("tor", "tor: Using SAFECOOKIE authentication, reading cookie authentication from %s\n", cookiefile);
|
||||||
std::pair<bool,std::string> status_cookie = ReadBinaryFile(cookiefile, TOR_COOKIE_SIZE);
|
std::pair<bool,std::string> status_cookie = ReadBinaryFile(cookiefile, TOR_COOKIE_SIZE);
|
||||||
if (status_cookie.first && status_cookie.second.size() == TOR_COOKIE_SIZE) {
|
if (status_cookie.first && status_cookie.second.size() == TOR_COOKIE_SIZE) {
|
||||||
// conn.Command("AUTHENTICATE " + HexStr(status_cookie.second), boost::bind(&TorController::auth_cb, this, _1, _2));
|
// _conn.Command("AUTHENTICATE " + HexStr(status_cookie.second), boost::bind(&TorController::auth_cb, this, _1, _2));
|
||||||
cookie = std::vector<uint8_t>(status_cookie.second.begin(), status_cookie.second.end());
|
cookie = std::vector<uint8_t>(status_cookie.second.begin(), status_cookie.second.end());
|
||||||
clientNonce = std::vector<uint8_t>(TOR_NONCE_SIZE, 0);
|
clientNonce = std::vector<uint8_t>(TOR_NONCE_SIZE, 0);
|
||||||
GetRandBytes(&clientNonce[0], TOR_NONCE_SIZE);
|
GetRandBytes(&clientNonce[0], TOR_NONCE_SIZE);
|
||||||
conn.Command("AUTHCHALLENGE SAFECOOKIE " + HexStr(clientNonce), boost::bind(&TorController::authchallenge_cb, this, _1, _2));
|
_conn.Command("AUTHCHALLENGE SAFECOOKIE " + HexStr(clientNonce), boost::bind(&TorController::authchallenge_cb, this, _1, _2));
|
||||||
} else {
|
} else {
|
||||||
if (status_cookie.first) {
|
if (status_cookie.first) {
|
||||||
LogPrintf("tor: Authentication cookie %s is not exactly %i bytes, as is required by the spec\n", cookiefile, TOR_COOKIE_SIZE);
|
LogPrintf("tor: Authentication cookie %s is not exactly %i bytes, as is required by the spec\n", cookiefile, TOR_COOKIE_SIZE);
|
||||||
|
@ -613,15 +613,15 @@ void TorController::protocolinfo_cb(TorControlConnection& conn, const TorControl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorController::connected_cb(TorControlConnection& conn)
|
void TorController::connected_cb(TorControlConnection& _conn)
|
||||||
{
|
{
|
||||||
reconnect_timeout = RECONNECT_TIMEOUT_START;
|
reconnect_timeout = RECONNECT_TIMEOUT_START;
|
||||||
// First send a PROTOCOLINFO command to figure out what authentication is expected
|
// First send a PROTOCOLINFO command to figure out what authentication is expected
|
||||||
if (!conn.Command("PROTOCOLINFO 1", boost::bind(&TorController::protocolinfo_cb, this, _1, _2)))
|
if (!_conn.Command("PROTOCOLINFO 1", boost::bind(&TorController::protocolinfo_cb, this, _1, _2)))
|
||||||
LogPrintf("tor: Error sending initial protocolinfo command\n");
|
LogPrintf("tor: Error sending initial protocolinfo command\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorController::disconnected_cb(TorControlConnection& conn)
|
void TorController::disconnected_cb(TorControlConnection& _conn)
|
||||||
{
|
{
|
||||||
// Stop advertising service when disconnected
|
// Stop advertising service when disconnected
|
||||||
if (service.IsValid())
|
if (service.IsValid())
|
||||||
|
|
|
@ -1116,8 +1116,8 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<uint256>* pvNoSpendsRe
|
||||||
std::vector<CTransaction> txn;
|
std::vector<CTransaction> txn;
|
||||||
if (pvNoSpendsRemaining) {
|
if (pvNoSpendsRemaining) {
|
||||||
txn.reserve(stage.size());
|
txn.reserve(stage.size());
|
||||||
BOOST_FOREACH(txiter it, stage)
|
BOOST_FOREACH(txiter iter, stage)
|
||||||
txn.push_back(it->GetTx());
|
txn.push_back(iter->GetTx());
|
||||||
}
|
}
|
||||||
RemoveStaged(stage, false);
|
RemoveStaged(stage, false);
|
||||||
if (pvNoSpendsRemaining) {
|
if (pvNoSpendsRemaining) {
|
||||||
|
@ -1125,8 +1125,8 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<uint256>* pvNoSpendsRe
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
|
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
|
||||||
if (exists(txin.prevout.hash))
|
if (exists(txin.prevout.hash))
|
||||||
continue;
|
continue;
|
||||||
auto it = mapNextTx.lower_bound(COutPoint(txin.prevout.hash, 0));
|
auto iter = mapNextTx.lower_bound(COutPoint(txin.prevout.hash, 0));
|
||||||
if (it == mapNextTx.end() || it->first->hash != txin.prevout.hash)
|
if (iter == mapNextTx.end() || iter->first->hash != txin.prevout.hash)
|
||||||
pvNoSpendsRemaining->push_back(txin.prevout.hash);
|
pvNoSpendsRemaining->push_back(txin.prevout.hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -401,8 +401,8 @@ set<uint256> CWallet::GetConflicts(const uint256& txid) const
|
||||||
if (mapTxSpends.count(txin.prevout) <= 1)
|
if (mapTxSpends.count(txin.prevout) <= 1)
|
||||||
continue; // No conflict if zero or one spends
|
continue; // No conflict if zero or one spends
|
||||||
range = mapTxSpends.equal_range(txin.prevout);
|
range = mapTxSpends.equal_range(txin.prevout);
|
||||||
for (TxSpends::const_iterator it = range.first; it != range.second; ++it)
|
for (TxSpends::const_iterator _it = range.first; _it != range.second; ++_it)
|
||||||
result.insert(it->second);
|
result.insert(_it->second);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1281,9 +1281,9 @@ int CWalletTx::GetRequestCount() const
|
||||||
// How about the block it's in?
|
// How about the block it's in?
|
||||||
if (nRequests == 0 && !hashUnset())
|
if (nRequests == 0 && !hashUnset())
|
||||||
{
|
{
|
||||||
map<uint256, int>::const_iterator mi = pwallet->mapRequestCount.find(hashBlock);
|
map<uint256, int>::const_iterator _mi = pwallet->mapRequestCount.find(hashBlock);
|
||||||
if (mi != pwallet->mapRequestCount.end())
|
if (_mi != pwallet->mapRequestCount.end())
|
||||||
nRequests = (*mi).second;
|
nRequests = (*_mi).second;
|
||||||
else
|
else
|
||||||
nRequests = 1; // If it's in someone else's block it must have got out
|
nRequests = 1; // If it's in someone else's block it must have got out
|
||||||
}
|
}
|
||||||
|
@ -2938,17 +2938,17 @@ set< set<CTxDestination> > CWallet::GetAddressGroupings()
|
||||||
|
|
||||||
set< set<CTxDestination>* > uniqueGroupings; // a set of pointers to groups of addresses
|
set< set<CTxDestination>* > uniqueGroupings; // a set of pointers to groups of addresses
|
||||||
map< CTxDestination, set<CTxDestination>* > setmap; // map addresses to the unique group containing it
|
map< CTxDestination, set<CTxDestination>* > setmap; // map addresses to the unique group containing it
|
||||||
BOOST_FOREACH(set<CTxDestination> grouping, groupings)
|
BOOST_FOREACH(set<CTxDestination> _grouping, groupings)
|
||||||
{
|
{
|
||||||
// make a set of all the groups hit by this new group
|
// make a set of all the groups hit by this new group
|
||||||
set< set<CTxDestination>* > hits;
|
set< set<CTxDestination>* > hits;
|
||||||
map< CTxDestination, set<CTxDestination>* >::iterator it;
|
map< CTxDestination, set<CTxDestination>* >::iterator it;
|
||||||
BOOST_FOREACH(CTxDestination address, grouping)
|
BOOST_FOREACH(CTxDestination address, _grouping)
|
||||||
if ((it = setmap.find(address)) != setmap.end())
|
if ((it = setmap.find(address)) != setmap.end())
|
||||||
hits.insert((*it).second);
|
hits.insert((*it).second);
|
||||||
|
|
||||||
// merge all hit groups into a new single group and delete old groups
|
// merge all hit groups into a new single group and delete old groups
|
||||||
set<CTxDestination>* merged = new set<CTxDestination>(grouping);
|
set<CTxDestination>* merged = new set<CTxDestination>(_grouping);
|
||||||
BOOST_FOREACH(set<CTxDestination>* hit, hits)
|
BOOST_FOREACH(set<CTxDestination>* hit, hits)
|
||||||
{
|
{
|
||||||
merged->insert(hit->begin(), hit->end());
|
merged->insert(hit->begin(), hit->end());
|
||||||
|
|
Loading…
Reference in a new issue