fix(blockrazor): wrap ArcSwap in Arc for Clone and static ping task

- Store gRPC client as Arc<ArcSwap<BlockRazorGrpcClient>> 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
This commit is contained in:
0xfnzero
2026-04-03 10:54:33 +08:00
parent 062c5415c3
commit 99846a21c2
+5 -2
View File
@@ -86,7 +86,7 @@ pub enum BlockRazorBackend {
Grpc {
endpoint: String,
auth_token: String,
grpc_client: ArcSwap<BlockRazorGrpcClient>,
grpc_client: Arc<ArcSwap<BlockRazorGrpcClient>>,
ping_handle: Arc<tokio::sync::Mutex<Option<JoinHandle<()>>>>,
stop_ping: Arc<AtomicBool>,
},
@@ -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));