Skip to content

Commit

Permalink
Enforce that there is only one changeset at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
sdaftuar committed Nov 13, 2024
1 parent 7fb62f7 commit 1882919
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/txmempool.h
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ class CTxMemPool
class ChangeSet {
public:
explicit ChangeSet(CTxMemPool* pool) : m_pool(pool) {}
~ChangeSet() = default;
~ChangeSet() EXCLUSIVE_LOCKS_REQUIRED(m_pool->cs) { m_pool->m_have_changeset = false; }

ChangeSet(const ChangeSet&) = delete;
ChangeSet& operator=(const ChangeSet&) = delete;
Expand Down Expand Up @@ -860,7 +860,13 @@ class CTxMemPool
friend class CTxMemPool;
};

std::unique_ptr<ChangeSet> GetChangeSet() EXCLUSIVE_LOCKS_REQUIRED(cs) { return std::make_unique<ChangeSet>(this); }
std::unique_ptr<ChangeSet> GetChangeSet() EXCLUSIVE_LOCKS_REQUIRED(cs) {
Assume(!m_have_changeset);
m_have_changeset = true;
return std::make_unique<ChangeSet>(this);
}

bool m_have_changeset GUARDED_BY(cs){false};

friend class CTxMemPool::ChangeSet;

Expand Down

0 comments on commit 1882919

Please sign in to comment.