Feature Request
Is your feature request related to a problem? Please describe.
OnionService polls GETINFO uptime every 3 seconds to check if Tor is alive (
|
self.handle.spawn(async move { |
|
let mut ticker = tokio::time::interval(tokio::time::Duration::from_secs(3)); |
|
loop { |
|
tokio::select! { |
|
_ = ticker.tick() => { |
|
let uptime = tor_controller.get_uptime().await; |
|
if let Err(err) = uptime { |
|
error!("Failed to get tor server uptime: {:?}", err); |
|
drop(tor_server_alive_tx); |
|
return; |
|
} |
|
} |
|
_ = stop_rx.cancelled() => { |
|
info!("OnionService received stop signal, exiting..."); |
|
drop(tor_server_alive_tx); |
|
return; |
|
} |
|
} |
|
} |
|
}); |
). This wastes control-port traffic and adds a 3-second blind window before CKB notices Tor is gone.
Describe the solution you'd like
React to the control-connection close instead of polling — either by detecting when the TcpStream closes, or by subscribing to SETEVENTS STATUS_CLIENT.
For reference, Bitcoin Core uses a libevent BEV_EVENT_EOF callback to detect the close instantly and then triggers a reconnect handler:
Feature Request
Is your feature request related to a problem? Please describe.
OnionServicepollsGETINFO uptimeevery 3 seconds to check if Tor is alive (ckb/util/onion/src/onion_service.rs
Lines 130 to 149 in 3d0da7c
Describe the solution you'd like
React to the control-connection close instead of polling — either by detecting when the
TcpStreamcloses, or by subscribing toSETEVENTS STATUS_CLIENT.For reference, Bitcoin Core uses a libevent
BEV_EVENT_EOFcallback to detect the close instantly and then triggers a reconnect handler: