mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-09 21:57:20 +01:00
refactor: remove RecursiveMutex cs_nBlockSequenceId
The RecursiveMutex cs_nBlockSequenceId is only used at one place in CChainState::ReceivedBlockTransactions() to atomically read-and-increment the nBlockSequenceId member. At this point, the cs_main lock is set, hence we can use a plain int for the member and mark it as guarded by cs_main.
This commit is contained in:
parent
33707a2a88
commit
0bd882b740
2 changed files with 3 additions and 7 deletions
|
@ -2970,10 +2970,7 @@ void CChainState::ReceivedBlockTransactions(const CBlock& block, CBlockIndex* pi
|
||||||
CBlockIndex *pindex = queue.front();
|
CBlockIndex *pindex = queue.front();
|
||||||
queue.pop_front();
|
queue.pop_front();
|
||||||
pindex->nChainTx = (pindex->pprev ? pindex->pprev->nChainTx : 0) + pindex->nTx;
|
pindex->nChainTx = (pindex->pprev ? pindex->pprev->nChainTx : 0) + pindex->nTx;
|
||||||
{
|
pindex->nSequenceId = nBlockSequenceId++;
|
||||||
LOCK(cs_nBlockSequenceId);
|
|
||||||
pindex->nSequenceId = nBlockSequenceId++;
|
|
||||||
}
|
|
||||||
if (m_chain.Tip() == nullptr || !setBlockIndexCandidates.value_comp()(pindex, m_chain.Tip())) {
|
if (m_chain.Tip() == nullptr || !setBlockIndexCandidates.value_comp()(pindex, m_chain.Tip())) {
|
||||||
setBlockIndexCandidates.insert(pindex);
|
setBlockIndexCandidates.insert(pindex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -558,9 +558,8 @@ protected:
|
||||||
* Every received block is assigned a unique and increasing identifier, so we
|
* Every received block is assigned a unique and increasing identifier, so we
|
||||||
* know which one to give priority in case of a fork.
|
* know which one to give priority in case of a fork.
|
||||||
*/
|
*/
|
||||||
RecursiveMutex cs_nBlockSequenceId;
|
|
||||||
/** Blocks loaded from disk are assigned id 0, so start the counter at 1. */
|
/** Blocks loaded from disk are assigned id 0, so start the counter at 1. */
|
||||||
int32_t nBlockSequenceId = 1;
|
int32_t nBlockSequenceId GUARDED_BY(::cs_main) = 1;
|
||||||
/** Decreasing counter (used by subsequent preciousblock calls). */
|
/** Decreasing counter (used by subsequent preciousblock calls). */
|
||||||
int32_t nBlockReverseSequenceId = -1;
|
int32_t nBlockReverseSequenceId = -1;
|
||||||
/** chainwork for the last block that preciousblock has been applied to. */
|
/** chainwork for the last block that preciousblock has been applied to. */
|
||||||
|
@ -749,7 +748,7 @@ public:
|
||||||
|
|
||||||
void PruneBlockIndexCandidates();
|
void PruneBlockIndexCandidates();
|
||||||
|
|
||||||
void UnloadBlockIndex();
|
void UnloadBlockIndex() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
||||||
|
|
||||||
/** Check whether we are doing an initial block download (synchronizing from disk or network) */
|
/** Check whether we are doing an initial block download (synchronizing from disk or network) */
|
||||||
bool IsInitialBlockDownload() const;
|
bool IsInitialBlockDownload() const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue