diff --git a/eth-rpc/server/serverdispatch.nim b/eth-rpc/server/serverdispatch.nim index 1effab0..020fd30 100644 --- a/eth-rpc/server/serverdispatch.nim +++ b/eth-rpc/server/serverdispatch.nim @@ -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 diff --git a/eth-rpc/server/servertypes.nim b/eth-rpc/server/servertypes.nim index a133823..1fc1954 100644 --- a/eth-rpc/server/servertypes.nim +++ b/eth-rpc/server/servertypes.nim @@ -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 \ No newline at end of file + server.procs[name] = rpc + +proc unRegisterAll*(server: RpcServer) = server.procs.clear diff --git a/tests/testserver.nim b/tests/testserver.nim index dbd98e8..973b84a 100644 --- a/tests/testserver.nim +++ b/tests/testserver.nim @@ -1,4 +1,4 @@ -import ../src/rpcserver, asyncdispatch +import ../eth-rpc/rpcserver, asyncdispatch when isMainModule: echo "Initialising server..."