tests: Add missing locking annotations and locks
This commit is contained in:
parent
07033a8f91
commit
b602c9b3af
2 changed files with 5 additions and 4 deletions
|
@ -70,7 +70,7 @@ struct COrphanTx {
|
||||||
NodeId fromPeer;
|
NodeId fromPeer;
|
||||||
int64_t nTimeExpire;
|
int64_t nTimeExpire;
|
||||||
};
|
};
|
||||||
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);
|
||||||
|
|
||||||
void EraseOrphansFor(NodeId peer);
|
void EraseOrphansFor(NodeId peer);
|
||||||
|
|
|
@ -31,7 +31,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)
|
||||||
{
|
{
|
||||||
|
@ -324,7 +325,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();
|
||||||
|
@ -394,7 +395,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 a new issue