From 249cabd64ef541dc92e6206172c30cb9080f799c Mon Sep 17 00:00:00 2001 From: Kim De Mey Date: Mon, 20 Mar 2023 17:25:34 +0100 Subject: [PATCH] Portal JSON-RPC API fixes (#1511) --- fluffy/rpc/rpc_discovery_api.nim | 25 ------------------------- fluffy/rpc/rpc_portal_api.nim | 8 ++++---- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/fluffy/rpc/rpc_discovery_api.nim b/fluffy/rpc/rpc_discovery_api.nim index bf576b81e..3705411e8 100644 --- a/fluffy/rpc/rpc_discovery_api.nim +++ b/fluffy/rpc/rpc_discovery_api.nim @@ -98,31 +98,6 @@ proc installDiscoveryApiHandlers*(rpcServer: RpcServer|RpcProxy, else: raise newException(ValueError, "Record not found in DHT lookup.") - # Note: - # These are difficult to support in our current discv5 implementation and it - # should be proven first that they are deemed useful before implementing them. - rpcServer.rpc("discv5_sendPing") do(enr: Record) -> string: - raise newException(ValueError, "This JSON-RPC is not supported") - - rpcServer.rpc("discv5_sendPong") do(enr: Record, requestId: string) -> bool: - raise newException(ValueError, "This JSON-RPC is not supported") - - rpcServer.rpc("discv5_sendFindNode") do( - enr: Record, distances: seq[uint16]) -> string: - raise newException(ValueError, "This JSON-RPC is not supported") - - rpcServer.rpc("discv5_sendNodes") do( - enr: Record, nodes: seq[Record], requestId: string) -> uint8: - raise newException(ValueError, "This JSON-RPC is not supported") - - rpcServer.rpc("discv5_sendTalkRequest") do( - enr: Record, protocolId: string, payload: string) -> string: - raise newException(ValueError, "This JSON-RPC is not supported") - - rpcServer.rpc("discv5_sendTalkResponse") do( - enr: Record, payload: string, requestId: string) -> bool: - raise newException(ValueError, "This JSON-RPC is not supported") - rpcServer.rpc("discv5_ping") do(enr: Record) -> PongResponse: let node = toNodeWithAddress(enr) diff --git a/fluffy/rpc/rpc_portal_api.nim b/fluffy/rpc/rpc_portal_api.nim index c3b942590..e4aed9c9b 100644 --- a/fluffy/rpc/rpc_portal_api.nim +++ b/fluffy/rpc/rpc_portal_api.nim @@ -195,9 +195,9 @@ proc installPortalApiHandlers*( raise newException(ValueError, "Invalid content key") contentResult = (await p.contentLookup(key, contentId)).valueOr: - raise newException(ValueError, "Content not found") + return "0x" - return contentResult.content.toHex() + return "0x" & contentResult.content.toHex() rpcServer.rpc("portal_" & network & "Store") do( contentKey: string, contentValue: string) -> bool: @@ -219,9 +219,9 @@ proc installPortalApiHandlers*( let contentResult = p.dbGet(key, contentId) if contentResult.isOk(): - return contentResult.get().toHex() + return "0x" & contentResult.get().toHex() else: - return "0x0" + return "0x" rpcServer.rpc("portal_" & network & "Gossip") do( contentKey: string, contentValue: string) -> int: