Minor updates

This commit is contained in:
coffeepots 2018-03-22 17:29:31 +00:00
parent 6dc45a9f9d
commit ff4e5b8f7d
3 changed files with 6 additions and 5 deletions

View File

@ -1,5 +1,5 @@
import asyncdispatch, asyncnet, json, tables, strutils,
servertypes, rpcconsts, private / [transportutils, debugutils], jsonutils, asyncutils, rpcprocs,
servertypes, rpcconsts, private / [transportutils, debugutils], jsonutils, asyncutils, ethprocs,
options
proc processMessage(server: RpcServer, client: AsyncSocket, line: string) {.async.} =
@ -20,7 +20,7 @@ proc processMessage(server: RpcServer, client: AsyncSocket, line: string) {.asyn
if not server.procs.hasKey(methodName):
await client.sendError(METHOD_NOT_FOUND, "Method not found", id, %(methodName & " is not a registered method."))
else:
let callRes = server.procs[methodName](node["params"]) # TODO: Performance or other effects from NOT calling rpc with await?
let callRes = server.procs[methodName](node["params"])
await client.send($wrapReply(id, callRes, newJNull()) & "\c\l")
proc processClient(server: RpcServer, client: AsyncSocket) {.async.} =
@ -29,7 +29,6 @@ proc processClient(server: RpcServer, client: AsyncSocket) {.async.} =
if line == "":
# Disconnected.
client.close()
echo server.port, " request with no data"
break
ifDebug: echo "Process client: ", server.port, ":" & line

View File

@ -22,4 +22,6 @@ proc newRpcServer*(address: string, port: Port = Port(8545)): RpcServer =
)
proc register*(server: RpcServer, name: string, rpc: RpcProc) =
server.procs[name] = rpc
server.procs[name] = rpc
proc unRegisterAll*(server: RpcServer) = server.procs.clear

View File

@ -1,4 +1,4 @@
import ../src/rpcserver, asyncdispatch
import ../eth-rpc/rpcserver, asyncdispatch
when isMainModule:
echo "Initialising server..."