From feb493df9c08176a5a544f835ee1436f81c78296 Mon Sep 17 00:00:00 2001 From: Dmitry Markin Date: Thu, 29 Aug 2024 13:58:53 +0000 Subject: [PATCH] Remove `try_get_record()` and other `try_...()` non-async methods --- src/protocol/libp2p/kademlia/handle.rs | 64 -------------------------- 1 file changed, 64 deletions(-) diff --git a/src/protocol/libp2p/kademlia/handle.rs b/src/protocol/libp2p/kademlia/handle.rs index f1b4c218..64c80a61 100644 --- a/src/protocol/libp2p/kademlia/handle.rs +++ b/src/protocol/libp2p/kademlia/handle.rs @@ -338,70 +338,6 @@ impl KademliaHandle { pub async fn store_record(&mut self, record: Record) { let _ = self.cmd_tx.send(KademliaCommand::StoreRecord { record }).await; } - - /// Try to add known peer and if the channel is clogged, return an error. - pub fn try_add_known_peer(&self, peer: PeerId, addresses: Vec) -> Result<(), ()> { - self.cmd_tx - .try_send(KademliaCommand::AddKnownPeer { peer, addresses }) - .map_err(|_| ()) - } - - /// Try to initiate `FIND_NODE` query and if the channel is clogged, return an error. - pub fn try_find_node(&mut self, peer: PeerId) -> Result { - let query_id = self.next_query_id(); - self.cmd_tx - .try_send(KademliaCommand::FindNode { peer, query_id }) - .map(|_| query_id) - .map_err(|_| ()) - } - - /// Try to initiate `PUT_VALUE` query and if the channel is clogged, return an error. - pub fn try_put_record(&mut self, record: Record) -> Result { - let query_id = self.next_query_id(); - self.cmd_tx - .try_send(KademliaCommand::PutRecord { record, query_id }) - .map(|_| query_id) - .map_err(|_| ()) - } - - /// Try to initiate `PUT_VALUE` query to the given peers and if the channel is clogged, - /// return an error. - pub fn try_put_record_to_peers( - &mut self, - record: Record, - peers: Vec, - update_local_store: bool, - ) -> Result { - let query_id = self.next_query_id(); - self.cmd_tx - .try_send(KademliaCommand::PutRecordToPeers { - record, - query_id, - peers, - update_local_store, - }) - .map(|_| query_id) - .map_err(|_| ()) - } - - /// Try to initiate `GET_VALUE` query and if the channel is clogged, return an error. - pub fn try_get_record(&mut self, key: RecordKey, quorum: Quorum) -> Result { - let query_id = self.next_query_id(); - self.cmd_tx - .try_send(KademliaCommand::GetRecord { - key, - quorum, - query_id, - }) - .map(|_| query_id) - .map_err(|_| ()) - } - - /// Try to store the record in the local store, and if the channel is clogged, return an error. - /// Used in combination with [`IncomingRecordValidationMode::Manual`]. - pub fn try_store_record(&mut self, record: Record) -> Result<(), ()> { - self.cmd_tx.try_send(KademliaCommand::StoreRecord { record }).map_err(|_| ()) - } } impl Stream for KademliaHandle {