Permalink
Browse files

remove fClient

  • Loading branch information...
Tranz5 committed Aug 20, 2014
1 parent d9a625a commit 6703b69c24315f7df6503a420cd3f32f6c067098
Showing with 26 additions and 109 deletions.
  1. +24 −90 src/main.cpp
  2. +0 −1 src/main.h
  3. +1 −2 src/net.cpp
  4. +0 −1 src/net.h
  5. +0 −7 src/txdb-bdb.cpp
  6. +0 −7 src/txdb-leveldb.cpp
  7. +1 −1 src/wallet.cpp
View
@@ -524,44 +524,36 @@ int CMerkleTx::SetMerkleBranch(const CBlock* pblock)
{
AssertLockHeld(cs_main);
- if (fClient)
+ CBlock blockTmp;
+ if (pblock == NULL)
{
- if (hashBlock == 0)
+ // Load the block this tx is in
+ CTxIndex txindex;
+ if (!CTxDB("r").ReadTxIndex(GetHash(), txindex))
+ return 0;
+ if (!blockTmp.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos))
return 0;
+ pblock = &blockTmp;
}
- else
- {
- CBlock blockTmp;
- if (pblock == NULL)
- {
- // Load the block this tx is in
- CTxIndex txindex;
- if (!CTxDB("r").ReadTxIndex(GetHash(), txindex))
- return 0;
- if (!blockTmp.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos))
- return 0;
- pblock = &blockTmp;
- }
- // Update the tx's hashBlock
- hashBlock = pblock->GetHash();
+ // Update the tx's hashBlock
+ hashBlock = pblock->GetHash();
- // Locate the transaction
- for (nIndex = 0; nIndex < (int)pblock->vtx.size(); nIndex++)
- if (pblock->vtx[nIndex] == *(CTransaction*)this)
- break;
- if (nIndex == (int)pblock->vtx.size())
- {
- vMerkleBranch.clear();
- nIndex = -1;
- printf("ERROR: SetMerkleBranch() : couldn't find tx in block\n");
- return 0;
- }
-
- // Fill in merkle branch
- vMerkleBranch = pblock->GetMerkleBranch(nIndex);
+ // Locate the transaction
+ for (nIndex = 0; nIndex < (int)pblock->vtx.size(); nIndex++)
+ if (pblock->vtx[nIndex] == *(CTransaction*)this)
+ break;
+ if (nIndex == (int)pblock->vtx.size())
+ {
+ vMerkleBranch.clear();
+ nIndex = -1;
+ printf("ERROR: SetMerkleBranch() : couldn't find tx in block\n");
+ return 0;
}
+ // Fill in merkle branch
+ vMerkleBranch = pblock->GetMerkleBranch(nIndex);
+
// Is the tx in a block that's in the main chain
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock);
if (mi == mapBlockIndex.end())
@@ -926,16 +918,7 @@ int CMerkleTx::GetBlocksToMaturity() const
bool CMerkleTx::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs)
{
- if (fClient)
- {
- if (!IsInMainChain() && !ClientConnectInputs())
- return false;
- return CTransaction::AcceptToMemoryPool(txdb, false);
- }
- else
- {
- return CTransaction::AcceptToMemoryPool(txdb, fCheckInputs);
- }
+ return CTransaction::AcceptToMemoryPool(txdb, fCheckInputs);
}
bool CMerkleTx::AcceptToMemoryPool()
@@ -1607,55 +1590,6 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, MapPrevTx inputs,
return true;
}
-
-bool CTransaction::ClientConnectInputs()
-{
- if (IsCoinBase())
- return false;
-
- // Take over previous transactions' spent pointers
- {
- int64 nValueIn = 0;
- for (unsigned int i = 0; i < vin.size(); i++)
- {
- // Get prev tx from single transactions in memory
- COutPoint prevout = vin[i].prevout;
- CTransaction txPrev;
- if (!mempool.lookup(prevout.hash, txPrev))
- return false;
-
- if (prevout.n >= txPrev.vout.size())
- return false;
-
- // Verify signature
- if (!VerifySignature(txPrev, *this, i, 0))
- return error("ConnectInputs() : VerifySignature failed");
-
- ///// this is redundant with the mempool.mapNextTx stuff,
- ///// not sure which I want to get rid of
- ///// this has to go away now that posNext is gone
- // // Check for conflicts
- // if (!txPrev.vout[prevout.n].posNext.IsNull())
- // return error("ConnectInputs() : prev tx already used");
- //
- // // Flag outpoints as used
- // txPrev.vout[prevout.n].posNext = posThisTx;
-
- nValueIn += txPrev.vout[prevout.n].nValue;
-
- if (!MoneyRange(txPrev.vout[prevout.n].nValue) || !MoneyRange(nValueIn))
- return error("ClientConnectInputs() : txin values out of range");
- }
- if (GetValueOut() > nValueIn)
- return false;
- }
-
- return true;
-}
-
-
-
-
bool CBlock::DisconnectBlock(CTxDB& txdb, CBlockIndex* pindex)
{
// Disconnect in reverse order
View
@@ -700,7 +700,6 @@ class CTransaction
bool ConnectInputs(CTxDB& txdb, MapPrevTx inputs,
std::map<uint256, CTxIndex>& mapTestPool, const CDiskTxPos& posThisTx,
const CBlockIndex* pindexBlock, bool fBlock, bool fMiner);
- bool ClientConnectInputs();
bool CheckTransaction() const;
bool AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs=true, bool* pfMissingInputs=NULL);
bool GetCoinAge(CTxDB& txdb, uint64& nCoinAge) const; // ppcoin: get transaction coin age
View
@@ -46,10 +46,9 @@ struct LocalServiceInfo {
//
// Global state variables
//
-bool fClient = false;
bool fDiscover = true;
bool fUseUPnP = false;
-uint64 nLocalServices = (fClient ? 0 : NODE_NETWORK);
+uint64 nLocalServices = NODE_NETWORK;
static CCriticalSection cs_mapLocalHost;
static map<CNetAddr, LocalServiceInfo> mapLocalHost;
static bool vfReachable[NET_MAX] = {};
View
@@ -113,7 +113,6 @@ enum threadId
THREAD_MAX
};
-extern bool fClient;
extern bool fDiscover;
extern bool fUseUPnP;
extern uint64 nLocalServices;
View
@@ -33,21 +33,17 @@ void MakeMockTXDB() {
bool CTxDB::ReadTxIndex(uint256 hash, CTxIndex& txindex)
{
- assert(!fClient);
txindex.SetNull();
return Read(make_pair(string("tx"), hash), txindex);
}
bool CTxDB::UpdateTxIndex(uint256 hash, const CTxIndex& txindex)
{
- assert(!fClient);
return Write(make_pair(string("tx"), hash), txindex);
}
bool CTxDB::AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeight)
{
- assert(!fClient);
-
// Add to tx index
uint256 hash = tx.GetHash();
CTxIndex txindex(pos, tx.vout.size());
@@ -56,21 +52,18 @@ bool CTxDB::AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeigh
bool CTxDB::EraseTxIndex(const CTransaction& tx)
{
- assert(!fClient);
uint256 hash = tx.GetHash();
return Erase(make_pair(string("tx"), hash));
}
bool CTxDB::ContainsTx(uint256 hash)
{
- assert(!fClient);
return Exists(make_pair(string("tx"), hash));
}
bool CTxDB::ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex)
{
- assert(!fClient);
tx.SetNull();
if (!ReadTxIndex(hash, txindex))
return false;
View
@@ -198,21 +198,17 @@ bool CTxDB::ScanBatch(const CDataStream &key, string *value, bool *deleted) cons
bool CTxDB::ReadTxIndex(uint256 hash, CTxIndex& txindex)
{
- assert(!fClient);
txindex.SetNull();
return Read(make_pair(string("tx"), hash), txindex);
}
bool CTxDB::UpdateTxIndex(uint256 hash, const CTxIndex& txindex)
{
- assert(!fClient);
return Write(make_pair(string("tx"), hash), txindex);
}
bool CTxDB::AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeight)
{
- assert(!fClient);
-
// Add to tx index
uint256 hash = tx.GetHash();
CTxIndex txindex(pos, tx.vout.size());
@@ -221,21 +217,18 @@ bool CTxDB::AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeigh
bool CTxDB::EraseTxIndex(const CTransaction& tx)
{
- assert(!fClient);
uint256 hash = tx.GetHash();
return Erase(make_pair(string("tx"), hash));
}
bool CTxDB::ContainsTx(uint256 hash)
{
- assert(!fClient);
return Exists(make_pair(string("tx"), hash));
}
bool CTxDB::ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex)
{
- assert(!fClient);
tx.SetNull();
if (!ReadTxIndex(hash, txindex))
return false;
View
@@ -810,7 +810,7 @@ void CWalletTx::AddSupportingTransactions(CTxDB& txdb)
{
tx = *mapWalletPrev[hash];
}
- else if (!fClient && txdb.ReadDiskTx(hash, tx))
+ else if (txdb.ReadDiskTx(hash, tx))
{
;
}

0 comments on commit 6703b69

Please sign in to comment.