From f9804c03513262dcc2f76bedaa6b3a7b5f7f74f5 Mon Sep 17 00:00:00 2001 From: Nikita Bishonen Date: Thu, 23 Jan 2025 05:26:41 +0000 Subject: [PATCH] fix(indexer): fixes inability to serialize Connection because of Arc. (#1253) Description --- Removes an Arc in Connection type. Motivation and Context --- With Arc type can't derive Serialize trait implementation. How Has This Been Tested? --- CI tests. What process can a PR reviewer use to test or verify this change? --- Breaking Changes --- - [x] None - [ ] Requires data directory to be deleted - [ ] Other - Please specify --- applications/tari_indexer/src/json_rpc/handlers.rs | 4 ++-- clients/tari_indexer_client/src/types.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/applications/tari_indexer/src/json_rpc/handlers.rs b/applications/tari_indexer/src/json_rpc/handlers.rs index a75796d55..fd52d9b29 100644 --- a/applications/tari_indexer/src/json_rpc/handlers.rs +++ b/applications/tari_indexer/src/json_rpc/handlers.rs @@ -20,7 +20,7 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use std::{collections::HashMap, fmt::Display, sync::Arc}; +use std::{collections::HashMap, fmt::Display, ops::Deref, sync::Arc}; use axum_jrpc::{ error::{JsonRpcError, JsonRpcErrorReason}, @@ -252,7 +252,7 @@ impl JsonRpcHandlers { }, age: conn.age(), ping_latency: conn.ping_latency, - user_agent: conn.user_agent, + user_agent: conn.user_agent.map(|arc| arc.deref().clone()), }) .collect(); diff --git a/clients/tari_indexer_client/src/types.rs b/clients/tari_indexer_client/src/types.rs index f4a8927db..55f97da02 100644 --- a/clients/tari_indexer_client/src/types.rs +++ b/clients/tari_indexer_client/src/types.rs @@ -1,7 +1,7 @@ // Copyright 2023 The Tari Project // SPDX-License-Identifier: BSD-3-Clause -use std::{sync::Arc, time::Duration}; +use std::time::Duration; use multiaddr::Multiaddr; use serde::{Deserialize, Serialize}; @@ -457,7 +457,7 @@ pub struct Connection { pub age: Duration, #[cfg_attr(feature = "ts", ts(type = "{secs: number, nanos: number} | null"))] pub ping_latency: Option, - pub user_agent: Option>, + pub user_agent: Option, } #[derive(Serialize, Debug)]