Devised a scheme for asynch messaging to bitcoind

And added some test code in Controller to use the scheme.

It's very asynchronous.  Needs some tuning long term to see how it deals
with load and perhaps throttle the requests if we know bitcoind is under
load.

But for right now, for testing, it should work ok.

Also in this commit small nits, plus bugfix to RPC::Message factory
methods (I forgot to populate some instance properties when constructing
the objects).

Additionally, we were registering the qMetaType wrong for RPC::Message
and RPC::Message::Id (this has been fixed).
This commit is contained in:
Calin Culianu 2019-11-18 14:32:48 +02:00
parent 0b6d6f0b70
commit f4091bb005
No known key found for this signature in database
GPG key ID: 21810A542031C02C
5 changed files with 144 additions and 15 deletions

View file

@ -169,6 +169,7 @@ namespace RPC {
if (!v1)
map["jsonrpc"] = RPC::jsonRpcVersion;
ret.v1 = v1;
ret.id = id;
map["id"] = id; // may be "null"
QVariantMap errMap;
errMap["code"] = code;
@ -190,6 +191,7 @@ namespace RPC {
map["error"] = QVariant(); // v1: always set the "error" key to null
map["id"] = reqId;
map["result"] = result;
ret.id = reqId;
return ret;
}
@ -199,6 +201,7 @@ namespace RPC {
Message ret = makeNotification(methodName, params, v1);
auto & map = ret.data;
map["id"] = id;
ret.id = id;
return ret;
}
@ -208,6 +211,7 @@ namespace RPC {
Message ret = makeNotification(methodName, params, v1);
auto & map = ret.data;
map["id"] = id;
ret.id = id;
return ret;
}
@ -223,6 +227,7 @@ namespace RPC {
map["id"] = QVariant(); // v1: always has the "id" key as null for a notif
map["method"] = methodName;
map["params"] = params;
ret.method = methodName;
return ret;
}
@ -238,6 +243,7 @@ namespace RPC {
map["id"] = QVariant(); // v1: always has the "id" key as null for a notif
map["method"] = methodName;
map["params"] = params;
ret.method = methodName;
return ret;
}