coins: assume entry is dirty in Next and Prev

This commit is contained in:
Andrew Toth 2024-08-31 14:19:38 -04:00
parent 2c3e62d452
commit 147cd50501
No known key found for this signature in database
GPG Key ID: 60007AFC8938B018
2 changed files with 5 additions and 6 deletions

View File

@ -181,17 +181,15 @@ public:
bool IsDirty() const noexcept { return m_flags & DIRTY; }
bool IsFresh() const noexcept { return m_flags & FRESH; }
//! Only call Next when this entry is DIRTY, FRESH, or both
CoinsCachePair* Next() const noexcept
{
Assume(m_flags);
Assume(IsDirty());
return m_next;
}
//! Only call Next when this entry is DIRTY, FRESH, or both
CoinsCachePair* Prev() const noexcept
{
Assume(m_flags);
Assume(IsDirty());
return m_prev;
}

View File

@ -154,9 +154,10 @@ BOOST_AUTO_TEST_CASE(linked_list_set_state)
BOOST_CHECK_EQUAL(sentinel.second.Next(), &n1);
BOOST_CHECK_EQUAL(sentinel.second.Prev(), &n1);
// Check that setting FRESH on new node inserts it after n1
// Check that setting DIRTY and FRESH on new node inserts it after n1
CCoinsCacheEntry::SetDirty(n2, sentinel);
CCoinsCacheEntry::SetFresh(n2, sentinel);
BOOST_CHECK(n2.second.IsFresh() && !n2.second.IsDirty());
BOOST_CHECK(n2.second.IsDirty() && n2.second.IsFresh());
BOOST_CHECK_EQUAL(n2.second.Next(), &sentinel);
BOOST_CHECK_EQUAL(n2.second.Prev(), &n1);
BOOST_CHECK_EQUAL(n1.second.Next(), &n2);