diff --git a/eth-rpc/server/cryptoutils.nim b/eth-rpc/server/cryptoutils.nim new file mode 100644 index 0000000..c9b9713 --- /dev/null +++ b/eth-rpc/server/cryptoutils.nim @@ -0,0 +1,8 @@ +import nimcrypto + +proc k256*(data: string): string = + # do not convert, assume string is data + var k = sha3_256() + k.init + k.update(cast[ptr uint8](data[0].unsafeaddr), data.len.uint) + result = $finish(k) diff --git a/eth-rpc/server/ethprocs.nim b/eth-rpc/server/ethprocs.nim index 9bbbeca..629a42e 100644 --- a/eth-rpc/server/ethprocs.nim +++ b/eth-rpc/server/ethprocs.nim @@ -1,25 +1,28 @@ import servertypes, json, asyncdispatch, rpcregistration -import keccak_tiny +import cryptoutils proc web3_clientVersion {.rpc.} = return %("Nimbus-RPC-Test") proc web3_sha3 {.rpc.} = - let - data = params.getStr - res = $sha3_256(data) - return %res + var data = params.getStr + let kres = k256(data) + return %kres proc net_version {.rpc.} = - discard - -proc net_peerCount {.rpc.} = - # TODO: Discovery integration + #[ See: + https://github.com/ethereum/interfaces/issues/6 + https://github.com/ethereum/EIPs/issues/611 + ]# discard proc net_listening {.rpc.} = return %"true" +proc net_peerCount {.rpc.} = + # TODO: Discovery integration + discard + proc eth_protocolVersion {.rpc.} = discard