MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / BlockConnected

Method BlockConnected

src/net_processing.cpp:862–892  ·  view source on GitHub ↗

* Evict orphan txn pool entries (EraseOrphanTx) based on a newly connected * block. Also save the time of the last tip update. */

Source from the content-addressed store, hash-verified

860 * block. Also save the time of the last tip update.
861 */
862void PeerLogicValidation::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted) {
863 LOCK(g_cs_orphans);
864
865 std::vector<uint256> vOrphanErase;
866
867 for (const CTransactionRef& ptx : pblock->vtx) {
868 const CTransaction& tx = *ptx;
869
870 // Which orphan pool entries must we evict?
871 for (const auto& txin : tx.vin) {
872 auto itByPrev = mapOrphanTransactionsByPrev.find(txin.prevout);
873 if (itByPrev == mapOrphanTransactionsByPrev.end()) continue;
874 for (auto mi = itByPrev->second.begin(); mi != itByPrev->second.end(); ++mi) {
875 const CTransaction& orphanTx = *(*mi)->second.tx;
876 const uint256& orphanHash = orphanTx.GetHash();
877 vOrphanErase.push_back(orphanHash);
878 }
879 }
880 }
881
882 // Erase orphan transactions included or precluded by this block
883 if (vOrphanErase.size()) {
884 int nErased = 0;
885 for (uint256 &orphanHash : vOrphanErase) {
886 nErased += EraseOrphanTx(orphanHash);
887 }
888 LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx included or conflicted by block\n", nErased);
889 }
890
891 g_last_tip_update = GetTime();
892}
893
894// All of the following cache a recent block, and are protected by cs_most_recent_block
895static CCriticalSection cs_most_recent_block;

Callers

nothing calls this directly

Calls 7

GetTimeFunction · 0.85
findMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
GetHashMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected