Clean up warnings: remove dead code, unused imports
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6aad2e073c
commit
409e44762a
4 changed files with 6 additions and 115 deletions
|
|
@ -25,7 +25,7 @@ use crate::protocol::{
|
||||||
SyncPost, VisibilityUpdatePayload, WormQueryPayload, WormResponsePayload,
|
SyncPost, VisibilityUpdatePayload, WormQueryPayload, WormResponsePayload,
|
||||||
ReplicationRequestPayload, ReplicationResponsePayload, ALPN_V2,
|
ReplicationRequestPayload, ReplicationResponsePayload, ALPN_V2,
|
||||||
};
|
};
|
||||||
use crate::storage::{Storage, StoragePool};
|
use crate::storage::StoragePool;
|
||||||
use crate::types::{
|
use crate::types::{
|
||||||
DeviceProfile, NodeId, PeerSlotKind, PeerWithAddress, PostId, PostVisibility, ReachMethod,
|
DeviceProfile, NodeId, PeerSlotKind, PeerWithAddress, PostId, PostVisibility, ReachMethod,
|
||||||
SessionReachMethod, SocialRouteEntry, SocialStatus, WormId, WormResult,
|
SessionReachMethod, SocialRouteEntry, SocialStatus, WormId, WormResult,
|
||||||
|
|
@ -2636,115 +2636,6 @@ impl ConnectionManager {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send a PostFetch request to a specific peer and return the post if found.
|
|
||||||
async fn send_post_fetch(
|
|
||||||
&self,
|
|
||||||
holder: &NodeId,
|
|
||||||
post_id: &PostId,
|
|
||||||
) -> anyhow::Result<Option<crate::protocol::SyncPost>> {
|
|
||||||
use crate::protocol::{PostFetchRequestPayload, PostFetchResponsePayload};
|
|
||||||
|
|
||||||
// Get connection to the holder (mesh or session)
|
|
||||||
let conn = self.connections.get(holder)
|
|
||||||
.map(|pc| pc.connection.clone())
|
|
||||||
.or_else(|| self.sessions.get(holder).map(|sc| sc.connection.clone()));
|
|
||||||
|
|
||||||
let conn = match conn {
|
|
||||||
Some(c) => c,
|
|
||||||
None => {
|
|
||||||
// Try to connect via endpoint (resolve address first)
|
|
||||||
let addr = self.resolve_address(holder).await.unwrap_or(None);
|
|
||||||
if let Some(addr_str) = addr {
|
|
||||||
let endpoint_id = iroh::EndpointId::from_bytes(holder)
|
|
||||||
.map_err(|_| anyhow::anyhow!("Invalid endpoint ID"))?;
|
|
||||||
let mut ep_addr = iroh::EndpointAddr::from(endpoint_id);
|
|
||||||
if let Ok(sock) = addr_str.parse::<std::net::SocketAddr>() {
|
|
||||||
ep_addr = ep_addr.with_ip_addr(sock);
|
|
||||||
}
|
|
||||||
self.endpoint.connect(ep_addr, ALPN_V2).await?
|
|
||||||
} else {
|
|
||||||
return Err(anyhow::anyhow!("No connection or address for post holder"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let (mut send, mut recv) = conn.open_bi().await?;
|
|
||||||
let req = PostFetchRequestPayload { post_id: *post_id };
|
|
||||||
write_typed_message(&mut send, MessageType::PostFetchRequest, &req).await?;
|
|
||||||
send.finish()?;
|
|
||||||
|
|
||||||
let msg_type = tokio::time::timeout(
|
|
||||||
std::time::Duration::from_secs(10),
|
|
||||||
read_message_type(&mut recv),
|
|
||||||
).await??;
|
|
||||||
|
|
||||||
if msg_type != MessageType::PostFetchResponse {
|
|
||||||
return Ok(None);
|
|
||||||
}
|
|
||||||
|
|
||||||
let resp: PostFetchResponsePayload = read_payload(&mut recv, MAX_PAYLOAD).await?;
|
|
||||||
Ok(resp.post)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Send a TcpPunchRequest to a peer, asking them to punch a TCP hole toward a browser IP.
|
|
||||||
/// Returns the peer's HTTP address if the punch succeeded.
|
|
||||||
async fn send_tcp_punch(
|
|
||||||
&self,
|
|
||||||
holder: &NodeId,
|
|
||||||
browser_ip: String,
|
|
||||||
post_id: &PostId,
|
|
||||||
) -> anyhow::Result<Option<String>> {
|
|
||||||
use crate::protocol::{TcpPunchRequestPayload, TcpPunchResultPayload};
|
|
||||||
|
|
||||||
// Get connection to the holder (mesh or session)
|
|
||||||
let conn = self.connections.get(holder)
|
|
||||||
.map(|pc| pc.connection.clone())
|
|
||||||
.or_else(|| self.sessions.get(holder).map(|sc| sc.connection.clone()));
|
|
||||||
|
|
||||||
let conn = match conn {
|
|
||||||
Some(c) => c,
|
|
||||||
None => {
|
|
||||||
// Try to connect via endpoint
|
|
||||||
let addr = self.resolve_address(holder).await.unwrap_or(None);
|
|
||||||
if let Some(addr_str) = addr {
|
|
||||||
let endpoint_id = iroh::EndpointId::from_bytes(holder)
|
|
||||||
.map_err(|_| anyhow::anyhow!("Invalid endpoint ID"))?;
|
|
||||||
let mut ep_addr = iroh::EndpointAddr::from(endpoint_id);
|
|
||||||
if let Ok(sock) = addr_str.parse::<std::net::SocketAddr>() {
|
|
||||||
ep_addr = ep_addr.with_ip_addr(sock);
|
|
||||||
}
|
|
||||||
self.endpoint.connect(ep_addr, ALPN_V2).await?
|
|
||||||
} else {
|
|
||||||
return Err(anyhow::anyhow!("No connection or address for punch target"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let (mut send, mut recv) = conn.open_bi().await?;
|
|
||||||
let req = TcpPunchRequestPayload {
|
|
||||||
browser_ip,
|
|
||||||
post_id: *post_id,
|
|
||||||
};
|
|
||||||
write_typed_message(&mut send, MessageType::TcpPunchRequest, &req).await?;
|
|
||||||
send.finish()?;
|
|
||||||
|
|
||||||
let msg_type = tokio::time::timeout(
|
|
||||||
std::time::Duration::from_secs(5),
|
|
||||||
read_message_type(&mut recv),
|
|
||||||
).await??;
|
|
||||||
|
|
||||||
if msg_type != MessageType::TcpPunchResult {
|
|
||||||
return Ok(None);
|
|
||||||
}
|
|
||||||
|
|
||||||
let resp: TcpPunchResultPayload = read_payload(&mut recv, 4096).await?;
|
|
||||||
if resp.success {
|
|
||||||
Ok(resp.http_addr)
|
|
||||||
} else {
|
|
||||||
Ok(None)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Fan out a worm query to multiple peers, collecting ALL responses.
|
/// Fan out a worm query to multiple peers, collecting ALL responses.
|
||||||
/// Returns (first_hit, all_wide_referrals).
|
/// Returns (first_hit, all_wide_referrals).
|
||||||
async fn fan_out_worm_query_all(
|
async fn fan_out_worm_query_all(
|
||||||
|
|
@ -4562,7 +4453,7 @@ impl ConnectionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connection ended unexpectedly — clean up and attempt reconnect
|
// Connection ended unexpectedly — clean up and attempt reconnect
|
||||||
let (is_current, peer_addr, has_social_route) = {
|
let (is_current, peer_addr, _has_social_route) = {
|
||||||
let mut cm = conn_mgr.lock().await;
|
let mut cm = conn_mgr.lock().await;
|
||||||
let is_current = cm.connections.get(&remote_node_id)
|
let is_current = cm.connections.get(&remote_node_id)
|
||||||
.map_or(false, |pc| pc.connection.stable_id() == our_stable_id);
|
.map_or(false, |pc| pc.connection.stable_id() == our_stable_id);
|
||||||
|
|
@ -7333,6 +7224,7 @@ impl ConnHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The actor task that processes commands by locking the shared ConnectionManager.
|
/// The actor task that processes commands by locking the shared ConnectionManager.
|
||||||
|
#[allow(dead_code)] // Hoisted fields used by unlocked handlers, not all consumed yet
|
||||||
pub struct ConnectionActor {
|
pub struct ConnectionActor {
|
||||||
cm: Arc<Mutex<ConnectionManager>>,
|
cm: Arc<Mutex<ConnectionManager>>,
|
||||||
rx: mpsc::Receiver<ConnCommand>,
|
rx: mpsc::Receiver<ConnCommand>,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use std::net::{IpAddr, SocketAddr};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
use tokio::net::{TcpListener, TcpStream};
|
use tokio::net::TcpStream;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use tracing::{debug, info};
|
use tracing::{debug, info};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ use crate::protocol::{
|
||||||
PullSyncRequestPayload, PullSyncResponsePayload, RefuseRedirectPayload,
|
PullSyncRequestPayload, PullSyncResponsePayload, RefuseRedirectPayload,
|
||||||
SocialAddressUpdatePayload, SocialDisconnectNoticePayload, SyncPost, ALPN_V2,
|
SocialAddressUpdatePayload, SocialDisconnectNoticePayload, SyncPost, ALPN_V2,
|
||||||
};
|
};
|
||||||
use crate::storage::{Storage, StoragePool};
|
use crate::storage::StoragePool;
|
||||||
use crate::types::{
|
use crate::types::{
|
||||||
DeleteRecord, DeviceProfile, DeviceRole, NodeId, PeerSlotKind, PeerWithAddress, Post, PostId,
|
DeleteRecord, DeviceProfile, DeviceRole, NodeId, PeerSlotKind, PeerWithAddress, Post, PostId,
|
||||||
PostVisibility, PublicProfile, SessionReachMethod, WormResult,
|
PostVisibility, PublicProfile, SessionReachMethod, WormResult,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ use std::path::{Path, PathBuf};
|
||||||
use std::sync::atomic::{AtomicU64, Ordering as AtomicOrdering};
|
use std::sync::atomic::{AtomicU64, Ordering as AtomicOrdering};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use tokio::sync::Mutex;
|
|
||||||
use tracing::{debug, info, warn};
|
use tracing::{debug, info, warn};
|
||||||
|
|
||||||
use crate::activity::{ActivityCategory, ActivityEvent, ActivityLevel, ActivityLog};
|
use crate::activity::{ActivityCategory, ActivityEvent, ActivityLevel, ActivityLog};
|
||||||
|
|
@ -11,7 +10,7 @@ use crate::blob::BlobStore;
|
||||||
use crate::content::compute_post_id;
|
use crate::content::compute_post_id;
|
||||||
use crate::crypto;
|
use crate::crypto;
|
||||||
use crate::network::Network;
|
use crate::network::Network;
|
||||||
use crate::storage::{Storage, StoragePool};
|
use crate::storage::StoragePool;
|
||||||
use crate::types::{
|
use crate::types::{
|
||||||
Attachment, AudienceDirection, AudienceRecord, AudienceStatus, Circle, DeleteRecord,
|
Attachment, AudienceDirection, AudienceRecord, AudienceStatus, Circle, DeleteRecord,
|
||||||
DeviceProfile, DeviceRole, NodeId, PeerRecord, PeerSlotKind, PeerWithAddress, Post, PostId,
|
DeviceProfile, DeviceRole, NodeId, PeerRecord, PeerSlotKind, PeerWithAddress, Post, PostId,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue