From 2f8272c2a4b6fa84c04dfeb4d751bb218f2d4c78 Mon Sep 17 00:00:00 2001 From: gzhao408 Date: Mon, 1 Feb 2021 15:24:30 -0800 Subject: [PATCH 1/3] [doc] GetBestBlock() doesn't do nothing This has tripped people up multiple times because it looks like GetBestBlock is a const function returning the value of hashBlock. --- src/validation.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/validation.cpp b/src/validation.cpp index d1b9efe7bac..7f1238f7953 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -690,7 +690,8 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws) } } - // Bring the best block into scope + // This is const, but calls into the back end CoinsViews. The CCoinsViewDB at the bottom of the + // hierarchy brings the best block into scope. See CCoinsViewDB::GetBestBlock(). m_view.GetBestBlock(); // we have all inputs cached now, so switch back to dummy (to protect From 8fa74aeb5b96419c7d40b40f8e1e1269509278e2 Mon Sep 17 00:00:00 2001 From: glozow Date: Tue, 23 Mar 2021 13:29:17 -0700 Subject: [PATCH 2/3] [doc] correct comment in chainparams There are more than 3 networks. --- src/chainparams.cpp | 9 +++++---- src/chainparams.h | 5 +---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 16efffa6f0f..28b64ee7ff3 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -56,7 +56,7 @@ static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits } /** - * Main network + * Main network on which people trade goods and services. */ class CMainParams : public CChainParams { public: @@ -173,7 +173,7 @@ public: }; /** - * Testnet (v3) + * Testnet (v3): public test network which is reset from time to time. */ class CTestNetParams : public CChainParams { public: @@ -266,7 +266,7 @@ public: }; /** - * Signet + * Signet: test network with an additional consensus parameter (see BIP325). */ class SigNetParams : public CChainParams { public: @@ -373,7 +373,8 @@ public: }; /** - * Regression test + * Regression test: intended for private networks only. Has minimal difficulty to ensure that + * blocks can be found instantly. */ class CRegTestParams : public CChainParams { public: diff --git a/src/chainparams.h b/src/chainparams.h index 013f075be65..6b43a441505 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -64,10 +64,7 @@ struct ChainTxData { /** * CChainParams defines various tweakable parameters of a given instance of the - * Bitcoin system. There are three: the main network on which people trade goods - * and services, the public test network which gets reset from time to time and - * a regression test mode which is intended for private networks only. It has - * minimal difficulty to ensure that blocks can be found instantly. + * Bitcoin system. */ class CChainParams { From 4eca20d6f7d850492d331d89d1cdd77abb3c70c1 Mon Sep 17 00:00:00 2001 From: glozow Date: Tue, 23 Mar 2021 13:32:03 -0700 Subject: [PATCH 3/3] [doc] correct comment about ATMPW ATMPW stands for AcceptToMemoryPoolWorker, which was removed in #16400. --- src/validation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 7f1238f7953..d0cb81b1f19 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1100,9 +1100,9 @@ static MempoolAcceptResult AcceptToMemoryPoolWithTime(const CChainParams& chainp assert(std::addressof(::ChainstateActive()) == std::addressof(active_chainstate)); const MempoolAcceptResult result = MemPoolAccept(pool, active_chainstate).AcceptSingleTransaction(tx, args); if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) { - // Remove coins that were not present in the coins cache before calling ATMPW; - // this is to prevent memory DoS in case we receive a large number of - // invalid transactions that attempt to overrun the in-memory coins cache + // Remove coins that were not present in the coins cache before calling + // AcceptSingleTransaction(); this is to prevent memory DoS in case we receive a large + // number of invalid transactions that attempt to overrun the in-memory coins cache // (`CCoinsViewCache::cacheCoins`). for (const COutPoint& hashTx : coins_to_uncache)