mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
Merge #14108: tests: Add missing locking annotations and locks (g_cs_orphans)
b602c9b3af tests: Add missing locking annotations and locks (practicalswift) Pull request description: Add missing locking annotations and locks. `mapOrphanTransactions` is guarded by `g_cs_orphans`. Tree-SHA512: f95104fbef23bd385e754c6bea3c3bdddd8a9c6a68e719d761227c9be1e46ff1316ec050a15a1243218dbab4e8584da6674f4a72f949f54b0a758392f19c83f8
This commit is contained in:
parent
259afa077c
commit
2890306a95
@ -115,7 +115,7 @@ struct COrphanTx {
|
|||||||
int64_t nTimeExpire;
|
int64_t nTimeExpire;
|
||||||
size_t nTxSize;
|
size_t nTxSize;
|
||||||
};
|
};
|
||||||
static CCriticalSection g_cs_orphans;
|
CCriticalSection g_cs_orphans;
|
||||||
std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY(g_cs_orphans);
|
std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY(g_cs_orphans);
|
||||||
|
|
||||||
size_t nMapOrphanTransactionsSize = 0;
|
size_t nMapOrphanTransactionsSize = 0;
|
||||||
|
@ -32,7 +32,8 @@ struct COrphanTx {
|
|||||||
NodeId fromPeer;
|
NodeId fromPeer;
|
||||||
int64_t nTimeExpire;
|
int64_t nTimeExpire;
|
||||||
};
|
};
|
||||||
extern std::map<uint256, COrphanTx> mapOrphanTransactions;
|
extern CCriticalSection g_cs_orphans;
|
||||||
|
extern std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY(g_cs_orphans);
|
||||||
|
|
||||||
static CService ip(uint32_t i)
|
static CService ip(uint32_t i)
|
||||||
{
|
{
|
||||||
@ -326,7 +327,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
|
|||||||
static CTransactionRef RandomOrphan()
|
static CTransactionRef RandomOrphan()
|
||||||
{
|
{
|
||||||
std::map<uint256, COrphanTx>::iterator it;
|
std::map<uint256, COrphanTx>::iterator it;
|
||||||
LOCK(cs_main);
|
LOCK2(cs_main, g_cs_orphans);
|
||||||
it = mapOrphanTransactions.lower_bound(InsecureRand256());
|
it = mapOrphanTransactions.lower_bound(InsecureRand256());
|
||||||
if (it == mapOrphanTransactions.end())
|
if (it == mapOrphanTransactions.end())
|
||||||
it = mapOrphanTransactions.begin();
|
it = mapOrphanTransactions.begin();
|
||||||
@ -396,7 +397,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
|
|||||||
BOOST_CHECK(!AddOrphanTx(MakeTransactionRef(tx), i));
|
BOOST_CHECK(!AddOrphanTx(MakeTransactionRef(tx), i));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK2(cs_main, g_cs_orphans);
|
||||||
// Test EraseOrphansFor:
|
// Test EraseOrphansFor:
|
||||||
for (NodeId i = 0; i < 3; i++)
|
for (NodeId i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user