aboutsummaryrefslogtreecommitdiff
path: root/src/httprpc.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-08-28 16:46:20 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2015-09-03 10:59:19 +0200
commitbe33f3f50b7358bbad9e16bf730fac2ab3c4886b (patch)
tree534b59ec81e5baf95c85980013304eb31b24d0c8 /src/httprpc.cpp
parent57d85d9bee20edb6c3070504f23b6a2be2802654 (diff)
downloadbitcoin-be33f3f50b7358bbad9e16bf730fac2ab3c4886b.tar.xz
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.
Diffstat (limited to 'src/httprpc.cpp')
-rw-r--r--src/httprpc.cpp22
1 files changed, 7 insertions, 15 deletions
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<void(void)>& func, int64_t seconds) : ev(eventBase, false, new Handler(func))
+ HTTPRPCTimer(struct event_base* eventBase, boost::function<void(void)>& 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<void(void)>& func) : func(func)
- {
- }
- private:
- boost::function<void(void)> func;
- void operator()() { func(); }
- };
};
class HTTPRPCTimerInterface : public RPCTimerInterface
@@ -49,9 +41,9 @@ public:
{
return "HTTP";
}
- RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t seconds)
+ RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis)
{
- return new HTTPRPCTimer(base, func, seconds);
+ return new HTTPRPCTimer(base, func, millis);
}
private:
struct event_base* base;