aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/walletdb.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet/walletdb.h')
-rw-r--r--src/wallet/walletdb.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h
index bffcc87202..32c3c29b5e 100644
--- a/src/wallet/walletdb.h
+++ b/src/wallet/walletdb.h
@@ -180,6 +180,11 @@ public:
}
};
+struct DbTxnListener
+{
+ std::function<void()> on_commit, on_abort;
+};
+
/** Access to the wallet database.
* Opens the database and provides read and write access to it. Each read and write is its own transaction.
* Multiple operation transactions can be started using TxnBegin() and committed using TxnCommit()
@@ -292,9 +297,18 @@ public:
bool TxnCommit();
//! Abort current transaction
bool TxnAbort();
+ bool HasActiveTxn() { return m_batch->HasActiveTxn(); }
+
+ //! Registers db txn callback functions
+ void RegisterTxnListener(const DbTxnListener& l);
+
private:
std::unique_ptr<DatabaseBatch> m_batch;
WalletDatabase& m_database;
+
+ // External functions listening to the current db txn outcome.
+ // Listeners are cleared at the end of the transaction.
+ std::vector<DbTxnListener> m_txn_listeners;
};
/**