Skip to content

Commit

Permalink
Undo style fix to ease upstream rebase
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Correa Casablanca <andres@thirdhash.com>
  • Loading branch information
Andres Correa Casablanca committed Jan 17, 2019
1 parent c6eb3c6 commit 08b2f68
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 200 deletions.
7 changes: 1 addition & 6 deletions src/coins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,9 @@ void AddCoins(CCoinsViewCache& cache, const CTransaction &tx, int nHeight, bool

bool CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin* moveout) {
CCoinsMap::iterator it = FetchCoin(outpoint);

if (it == cacheCoins.end()) {
return false;
}

if (it == cacheCoins.end()) return false;
cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage();
snapshotHash.SubtractUTXO(snapshot::UTXO(outpoint, it->second.coin));

if (moveout) {
*moveout = std::move(it->second.coin);
}
Expand Down
9 changes: 3 additions & 6 deletions src/consensus/tx_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,17 @@ unsigned int GetLegacySigOpCount(const CTransaction& tx)

unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& inputs)
{
if (tx.IsCoinBase()) {
if (tx.IsCoinBase())
return 0;
}

unsigned int nSigOps = 0;
for (unsigned int i = 0; i < tx.vin.size(); i++)
{
const Coin& coin = inputs.AccessCoin(tx.vin[i].prevout);
assert(!coin.IsSpent());
const CTxOut &prevout = coin.out;
if (prevout.scriptPubKey.IsPayToScriptHash()) {
if (prevout.scriptPubKey.IsPayToScriptHash())
nSigOps += prevout.scriptPubKey.GetSigOpCount(tx.vin[i].scriptSig);
}
}
return nSigOps;
}
Expand All @@ -144,9 +142,8 @@ int64_t GetTransactionSigOpCost(const CTransaction& tx, const CCoinsViewCache& i
{
int64_t nSigOps = GetLegacySigOpCount(tx) * WITNESS_SCALE_FACTOR;

if (tx.IsCoinBase()) {
if (tx.IsCoinBase())
return nSigOps;
}

if (flags & SCRIPT_VERIFY_P2SH) {
nSigOps += GetP2SHSigOpCount(tx, inputs) * WITNESS_SCALE_FACTOR;
Expand Down
10 changes: 2 additions & 8 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1672,14 +1672,8 @@ bool AppInitMain()
}
}

if (
!CVerifyDB().VerifyDB(
chainparams,
pcoinsdbview.get(),
gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL),
gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS)
)
) {
if (!CVerifyDB().VerifyDB(chainparams, pcoinsdbview.get(), gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL),
gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS))) {
strLoadError = _("Corrupted block database detected");
break;
}
Expand Down
20 changes: 8 additions & 12 deletions src/txmempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,16 @@ void CTxMemPool::UpdateChildrenForRemoval(txiter it)

void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, bool updateDescendants)
{
// For each entry, walk back all ancestors and decrement size associated
// with this transaction
// For each entry, walk back all ancestors and decrement size associated with this
// transaction
const uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
if (updateDescendants) {
// updateDescendants should be true whenever we're not recursively
// removing a tx and all its descendants, eg when a transaction is
// confirmed in a block.
// Here we only update statistics and not data in mapLinks (which we
// need to preserve until we're finished with all operations that need
// to traverse the mempool).
// Here we only update statistics and not data in mapLinks (which
// we need to preserve until we're finished with all operations that
// need to traverse the mempool).
for (txiter removeIt : entriesToRemove) {
setEntries setDescendants;
CalculateDescendants(removeIt, setDescendants);
Expand Down Expand Up @@ -575,16 +575,12 @@ void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigne
uint256 hash = (*ptx)->GetHash();

indexed_transaction_set::iterator i = mapTx.find(hash);
if (i != mapTx.end()) {
if (i != mapTx.end())
entries.push_back(&*i);
}
}

// Before the txs in the new block have been removed from the mempool,
// update policy estimates
if (minerPolicyEstimator) {
minerPolicyEstimator->processBlock(nBlockHeight, entries);
}
// Before the txs in the new block have been removed from the mempool, update policy estimates
if (minerPolicyEstimator) {minerPolicyEstimator->processBlock(nBlockHeight, entries);}

for (auto ptx = begin_it; ptx != end_it; ptx++) {
auto tx = *ptx;
Expand Down
4 changes: 1 addition & 3 deletions src/txmempool.h
Original file line number Diff line number Diff line change
Expand Up @@ -765,9 +765,7 @@ struct DisconnectedBlockTransactions {
// Estimate the overhead of queuedTx to be 6 pointers + an allocation, as
// no exact formula for boost::multi_index_contained is implemented.
size_t DynamicMemoryUsage() const {
return memusage::MallocUsage(
sizeof(CTransactionRef) + 6 * sizeof(void*)
) * queuedTx.size() + cachedInnerUsage;
return memusage::MallocUsage(sizeof(CTransactionRef) + 6 * sizeof(void*)) * queuedTx.size() + cachedInnerUsage;
}

const indexed_disconnected_transactions &GetQueuedTx() const {
Expand Down
Loading

0 comments on commit 08b2f68

Please sign in to comment.