From 99846a21c2ccbce51ac4080390988ef7974a511c Mon Sep 17 00:00:00 2001 From: 0xfnzero <0xfnzero@users.noreply.github.com> Date: Fri, 3 Apr 2026 10:54:18 +0800 Subject: [PATCH] fix(blockrazor): wrap ArcSwap in Arc for Clone and static ping task - Store gRPC client as Arc> so BlockRazorBackend can derive Clone (ArcSwap does not implement Clone). - Cloning the outer Arc gives owned handles for tokio::spawn in start_ping_task, fixing E0521 (borrowed self escaping to 'static future). Made-with: Cursor --- src/swqos/blockrazor.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/swqos/blockrazor.rs b/src/swqos/blockrazor.rs index f57ee63..87d4a59 100644 --- a/src/swqos/blockrazor.rs +++ b/src/swqos/blockrazor.rs @@ -86,7 +86,7 @@ pub enum BlockRazorBackend { Grpc { endpoint: String, auth_token: String, - grpc_client: ArcSwap, + grpc_client: Arc>, ping_handle: Arc>>>, stop_ping: Arc, }, @@ -158,7 +158,10 @@ impl BlockRazorClient { .await .map_err(|e| anyhow::anyhow!("Failed to connect to gRPC endpoint: {}", e))?; - let grpc_client = ArcSwap::from_pointee(BlockRazorGrpcClient::new(channel, auth_token.clone())); + let grpc_client = Arc::new(ArcSwap::from_pointee(BlockRazorGrpcClient::new( + channel, + auth_token.clone(), + ))); let ping_handle = Arc::new(tokio::sync::Mutex::new(None)); let stop_ping = Arc::new(AtomicBool::new(false));