use alloy::primitives::bytes::Bytes;
use discv5::enr::NodeId;
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
use crate::types::{
discv5::{NodeInfo, Pong, RoutingTableInfo},
enr::Enr,
network::Subnetwork,
};
#[rpc(client, server, namespace = "discv5")]
pub trait Discv5Api {
#[method(name = "nodeInfo")]
async fn node_info(&self) -> RpcResult<NodeInfo>;
#[method(name = "updateNodeInfo")]
async fn update_node_info(&self, socket_addr: String, is_tcp: bool) -> RpcResult<NodeInfo>;
#[method(name = "routingTableInfo")]
async fn routing_table_info(&self) -> RpcResult<RoutingTableInfo>;
#[method(name = "addEnr")]
async fn add_enr(&self, enr: Enr) -> RpcResult<bool>;
#[method(name = "getEnr")]
async fn get_enr(&self, node_id: NodeId) -> RpcResult<Enr>;
#[method(name = "deleteEnr")]
async fn delete_enr(&self, node_id: NodeId) -> RpcResult<bool>;
#[method(name = "lookupEnr")]
async fn lookup_enr(&self, node_id: NodeId) -> RpcResult<Enr>;
#[method(name = "recursiveFindNodes")]
async fn recursive_find_nodes(&self, node_id: NodeId) -> RpcResult<Vec<Enr>>;
#[method(name = "talkReq")]
async fn talk_req(&self, enr: Enr, protocol: Subnetwork, request: Vec<u8>) -> RpcResult<Bytes>;
#[method(name = "ping")]
async fn ping(&self, enr: Enr) -> RpcResult<Pong>;
#[method(name = "findNode")]
async fn find_node(&self, enr: Enr, distances: Vec<u64>) -> RpcResult<Vec<Enr>>;
}