Skip to content

Commit 1882919

Browse files
committed
Enforce that there is only one changeset at a time
1 parent 7fb62f7 commit 1882919

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/txmempool.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ class CTxMemPool
811811
class ChangeSet {
812812
public:
813813
explicit ChangeSet(CTxMemPool* pool) : m_pool(pool) {}
814-
~ChangeSet() = default;
814+
~ChangeSet() EXCLUSIVE_LOCKS_REQUIRED(m_pool->cs) { m_pool->m_have_changeset = false; }
815815

816816
ChangeSet(const ChangeSet&) = delete;
817817
ChangeSet& operator=(const ChangeSet&) = delete;
@@ -860,7 +860,13 @@ class CTxMemPool
860860
friend class CTxMemPool;
861861
};
862862

863-
std::unique_ptr<ChangeSet> GetChangeSet() EXCLUSIVE_LOCKS_REQUIRED(cs) { return std::make_unique<ChangeSet>(this); }
863+
std::unique_ptr<ChangeSet> GetChangeSet() EXCLUSIVE_LOCKS_REQUIRED(cs) {
864+
Assume(!m_have_changeset);
865+
m_have_changeset = true;
866+
return std::make_unique<ChangeSet>(this);
867+
}
868+
869+
bool m_have_changeset GUARDED_BY(cs){false};
864870

865871
friend class CTxMemPool::ChangeSet;
866872

0 commit comments

Comments
 (0)