Browse Source

Globals: Explicitly pass const CChainParams& to UpdateTip()

0.13
Jorge Timón 8 years ago committed by Nikolay Mitev
parent
commit
764d237772
  1. 8
      src/main.cpp

8
src/main.cpp

@ -2570,8 +2570,7 @@ void PruneAndFlush() {
} }
/** Update chainActive and related internal data structures. */ /** Update chainActive and related internal data structures. */
void static UpdateTip(CBlockIndex *pindexNew) { void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
const CChainParams& chainParams = Params();
chainActive.SetTip(pindexNew); chainActive.SetTip(pindexNew);
// New best block // New best block
@ -2631,6 +2630,7 @@ void static UpdateTip(CBlockIndex *pindexNew) {
/** Disconnect chainActive's tip. You probably want to call mempool.removeForReorg and manually re-limit mempool size after this, with cs_main held. */ /** Disconnect chainActive's tip. You probably want to call mempool.removeForReorg and manually re-limit mempool size after this, with cs_main held. */
bool static DisconnectTip(CValidationState& state, const Consensus::Params& consensusParams) bool static DisconnectTip(CValidationState& state, const Consensus::Params& consensusParams)
{ {
const CChainParams& chainparams = Params(); // TODO replace consensusParams parameter
CBlockIndex *pindexDelete = chainActive.Tip(); CBlockIndex *pindexDelete = chainActive.Tip();
assert(pindexDelete); assert(pindexDelete);
// Read block from disk. // Read block from disk.
@ -2668,7 +2668,7 @@ bool static DisconnectTip(CValidationState& state, const Consensus::Params& cons
// block that were added back and cleans up the mempool state. // block that were added back and cleans up the mempool state.
mempool.UpdateTransactionsFromBlock(vHashUpdate); mempool.UpdateTransactionsFromBlock(vHashUpdate);
// Update chainActive and related variables. // Update chainActive and related variables.
UpdateTip(pindexDelete->pprev); UpdateTip(pindexDelete->pprev, chainparams);
// Let wallets know transactions went from 1-confirmed to // Let wallets know transactions went from 1-confirmed to
// 0-confirmed or conflicted: // 0-confirmed or conflicted:
BOOST_FOREACH(const CTransaction &tx, block.vtx) { BOOST_FOREACH(const CTransaction &tx, block.vtx) {
@ -2727,7 +2727,7 @@ bool static ConnectTip(CValidationState& state, const CChainParams& chainparams,
list<CTransaction> txConflicted; list<CTransaction> txConflicted;
mempool.removeForBlock(pblock->vtx, pindexNew->nHeight, txConflicted, !IsInitialBlockDownload()); mempool.removeForBlock(pblock->vtx, pindexNew->nHeight, txConflicted, !IsInitialBlockDownload());
// Update chainActive & related variables. // Update chainActive & related variables.
UpdateTip(pindexNew); UpdateTip(pindexNew, chainparams);
// Tell wallet about transactions that went from mempool // Tell wallet about transactions that went from mempool
// to conflicted: // to conflicted:
BOOST_FOREACH(const CTransaction &tx, txConflicted) { BOOST_FOREACH(const CTransaction &tx, txConflicted) {

Loading…
Cancel
Save