Merge bitcoin/bitcoin#32862: rpc: use CScheduler for relocking wallet and remove RPCTimer
fcfd3db563remove RPCTimerInterface and RPCRunLater (Matthew Zipkin)8a1765795fuse WalletContext scheduler for walletpassphrase callback (Matthew Zipkin) Pull request description: This removes the dependency on libevent for events scheduled by RPC commands, like re-locking a wallet some time after decryption with walletpassphrase. Since walletpassphrase is currently the only RPC that does this, `RPCRunLater`, `RPCTimerInterface` and all related methods are left unused, and deleted in the second commit. Any future RPC that needs to execute a callback in the future can follow the pattern in this PR and just use a scheduler from node or wallet context. This is an alternative approach to #32796, described in https://github.com/bitcoin/bitcoin/pull/32796#issuecomment-3014309449 ACKs for top commit: fjahr: Code Review ACKfcfd3db563achow101: ACKfcfd3db563furszy: ACKfcfd3db563Tree-SHA512: 04f5e9c3f73f598c3d41d6e35bb59c64c7b93b03ad9fce3c40901733147ce7764f41f475fef1527d44af18f722759996a31ca83b48cb52153795d5022fecfd14
This commit is contained in:
10 files changed
+14
-187
No files matched your search
@@ -98,37 +98,6 @@ private:
|
||||
interfaces::Node& m_node;
|
||||
};
|
||||
|
||||
/** Class for handling RPC timers
|
||||
* (used for e.g. re-locking the wallet after a timeout)
|
||||
*/
|
||||
class QtRPCTimerBase: public QObject, public RPCTimerBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtRPCTimerBase(std::function<void()>& _func, int64_t millis):
|
||||
func(_func)
|
||||
{
|
||||
timer.setSingleShot(true);
|
||||
connect(&timer, &QTimer::timeout, [this]{ func(); });
|
||||
timer.start(millis);
|
||||
}
|
||||
~QtRPCTimerBase() = default;
|
||||
private:
|
||||
QTimer timer;
|
||||
std::function<void()> func;
|
||||
};
|
||||
|
||||
class QtRPCTimerInterface: public RPCTimerInterface
|
||||
{
|
||||
public:
|
||||
~QtRPCTimerInterface() = default;
|
||||
const char *Name() override { return "Qt"; }
|
||||
RPCTimerBase* NewTimer(std::function<void()>& func, int64_t millis) override
|
||||
{
|
||||
return new QtRPCTimerBase(func, millis);
|
||||
}
|
||||
};
|
||||
|
||||
class PeerIdViewDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -567,12 +536,6 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
|
||||
ui->WalletSelector->setVisible(false);
|
||||
ui->WalletSelectorLabel->setVisible(false);
|
||||
|
||||
// Register RPC timer interface
|
||||
rpcTimerInterface = new QtRPCTimerInterface();
|
||||
// avoid accidentally overwriting an existing, non QTThread
|
||||
// based timer interface
|
||||
m_node.rpcSetTimerInterfaceIfUnset(rpcTimerInterface);
|
||||
|
||||
setTrafficGraphRange(INITIAL_TRAFFIC_GRAPH_MINS);
|
||||
updateDetailWidget();
|
||||
|
||||
@@ -602,8 +565,6 @@ RPCConsole::~RPCConsole()
|
||||
settings.setValue("PeersTabPeerHeaderState", m_peer_widget_header_state);
|
||||
settings.setValue("PeersTabBanlistHeaderState", m_banlist_widget_header_state);
|
||||
|
||||
m_node.rpcUnsetTimerInterface(rpcTimerInterface);
|
||||
delete rpcTimerInterface;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
class PlatformStyle;
|
||||
class RPCExecutor;
|
||||
class RPCTimerInterface;
|
||||
class WalletModel;
|
||||
|
||||
namespace interfaces {
|
||||
@@ -166,7 +165,6 @@ private:
|
||||
QString cmdBeforeBrowsing;
|
||||
QList<NodeId> cachedNodeids;
|
||||
const PlatformStyle* const platformStyle;
|
||||
RPCTimerInterface *rpcTimerInterface = nullptr;
|
||||
QMenu *peersTableContextMenu = nullptr;
|
||||
QMenu *banTableContextMenu = nullptr;
|
||||
int consoleFontSize = 0;
|
||||
|
||||
Reference in new issue
Block a user