From 1ff985b468a3d6ebe1fe179b95879f1ef9865747 Mon Sep 17 00:00:00 2001 From: cheatfate Date: Tue, 12 Jun 2018 09:49:16 +0300 Subject: [PATCH 1/2] Fix for latest changes in asyncdispatch2. --- eth-rpc/server.nim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/eth-rpc/server.nim b/eth-rpc/server.nim index 00ef4b8..782f658 100644 --- a/eth-rpc/server.nim +++ b/eth-rpc/server.nim @@ -80,8 +80,9 @@ proc sendError*(client: StreamTransport, code: int, msg: string, id: JsonNode, data: JsonNode = newJNull()) {.async.} = ## Send error message to client let error = %{"code": %(code), "message": %msg, "data": data} - ifDebug: echo "Send error json: ", wrapReply(newJNull(), error, id) - result = client.write(wrapReply(id, newJNull(), error)) + var res = wrapReply(id, newJNull(), error) + ifDebug: echo "Send error json: ", res + result = client.write(res) proc sendJsonError*(state: RpcJsonError, client: StreamTransport, id: JsonNode, data = newJNull()) {.async.} = @@ -110,7 +111,8 @@ proc processMessage(server: RpcServer, client: StreamTransport, %(methodName & " is not a registered method.")) else: let callRes = await server.procs[methodName](node["params"]) - discard await client.write(wrapReply(id, callRes, newJNull())) + var res = wrapReply(id, callRes, newJNull()) + discard await client.write(res) proc processClient(server: StreamServer, client: StreamTransport) {.async.} = var rpc = getUserData[RpcServer](server) From 001195341c9554339d37744aa8ab50db493ebe43 Mon Sep 17 00:00:00 2001 From: cheatfate Date: Tue, 12 Jun 2018 09:53:48 +0300 Subject: [PATCH 2/2] Fix client.nim for latest changes in asyncdispatch2. --- eth-rpc/client.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth-rpc/client.nim b/eth-rpc/client.nim index 581cba5..9a5d216 100644 --- a/eth-rpc/client.nim +++ b/eth-rpc/client.nim @@ -19,7 +19,7 @@ proc call*(self: RpcClient, name: string, ## Remotely calls the specified RPC method. let id = $self.nextId self.nextId.inc - let msg = $ %{"jsonrpc": %"2.0", "method": %name, "params": params, + var msg = $ %{"jsonrpc": %"2.0", "method": %name, "params": params, "id": %id} & "\c\l" let res = await self.transp.write(msg) # TODO: Add actions when not full packet was send, e.g. disconnect peer.