protect g_chainman with cs_main

I'd previously attempted to create a specialized lock for ChainstateManager,
but it turns out that because that lock would be required for functions like
ChainActive() and ChainstateActive(), it created irreconcilable lock inversions
since those functions are used so broadly throughout the codebase.

Instead, I'm just using cs_main to protect the contents of g_chainman.

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
This commit is contained in:
James O'BeirneandRussell Yanofsky committed 2020-03-17 14:07:58 -04:00
1 parent 2b081c4568
commit c9017ce3bc
5 files changed
+48 -11

No files matched your search

+1 -1
View File
@@ -454,7 +454,7 @@ public:
CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
wallet = MakeUnique<CWallet>(m_chain.get(), WalletLocation(), WalletDatabase::CreateMock());
{
LOCK(wallet->cs_wallet);
LOCK2(::cs_main, wallet->cs_wallet);
wallet->SetLastBlockProcessed(::ChainActive().Height(), ::ChainActive().Tip()->GetBlockHash());
}
bool firstRun;