From be33f3f50b7358bbad9e16bf730fac2ab3c4886b Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 28 Aug 2015 16:46:20 +0200 Subject: Implement RPCTimerHandler for Qt RPC console Implement RPCTimerHandler for Qt RPC console, so that `walletpassphrase` works with GUI and `-server=0`. Also simplify HTTPEvent-related code by using boost::function directly. --- src/httprpc.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'src/httprpc.cpp') diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 570beadc5f..98ac750bb1 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -19,24 +19,16 @@ class HTTPRPCTimer : public RPCTimerBase { public: - HTTPRPCTimer(struct event_base* eventBase, boost::function& func, int64_t seconds) : ev(eventBase, false, new Handler(func)) + HTTPRPCTimer(struct event_base* eventBase, boost::function& func, int64_t millis) : + ev(eventBase, false, func) { - struct timeval tv = {seconds, 0}; + struct timeval tv; + tv.tv_sec = millis/1000; + tv.tv_usec = (millis%1000)*1000; ev.trigger(&tv); } private: HTTPEvent ev; - - class Handler : public HTTPClosure - { - public: - Handler(const boost::function& func) : func(func) - { - } - private: - boost::function func; - void operator()() { func(); } - }; }; class HTTPRPCTimerInterface : public RPCTimerInterface @@ -49,9 +41,9 @@ public: { return "HTTP"; } - RPCTimerBase* NewTimer(boost::function& func, int64_t seconds) + RPCTimerBase* NewTimer(boost::function& func, int64_t millis) { - return new HTTPRPCTimer(base, func, seconds); + return new HTTPRPCTimer(base, func, millis); } private: struct event_base* base; -- cgit v1.2.3