This commit is contained in:
John Smith
2022-11-04 19:29:44 -04:00
parent 60c4648530
commit ed0049dc22
9 changed files with 497 additions and 142 deletions

View File

@@ -1747,7 +1747,7 @@ impl NetworkManager {
// Ignore these reports if we are currently detecting public dial info
let net = self.net();
if net.doing_public_dial_info_check() {
if net.needs_public_dial_info_check() {
return;
}

View File

@@ -63,8 +63,6 @@ struct NetworkInner {
enable_ipv6_local: bool,
/// set if we need to calculate our public dial info again
needs_public_dial_info_check: bool,
/// set during the actual execution of the public dial info check to ensure we don't do it more than once
doing_public_dial_info_check: bool,
/// the punishment closure to enax
public_dial_info_check_punishment: Option<Box<dyn FnOnce() + Send + 'static>>,
/// udp socket record for bound-first sockets, which are used to guarantee a port is available before
@@ -116,7 +114,6 @@ impl Network {
network_started: false,
network_needs_restart: false,
needs_public_dial_info_check: false,
doing_public_dial_info_check: false,
public_dial_info_check_punishment: None,
protocol_config: Default::default(),
static_public_dialinfo: ProtocolTypeSet::empty(),
@@ -871,16 +868,11 @@ impl Network {
inner.public_dial_info_check_punishment = punishment;
}
fn needs_public_dial_info_check(&self) -> bool {
pub fn needs_public_dial_info_check(&self) -> bool {
let inner = self.inner.lock();
inner.needs_public_dial_info_check
}
pub fn doing_public_dial_info_check(&self) -> bool {
let inner = self.inner.lock();
inner.doing_public_dial_info_check
}
//////////////////////////////////////////
#[instrument(level = "trace", skip(self), err)]

View File

@@ -883,15 +883,11 @@ impl Network {
l: u64,
t: u64,
) -> EyreResult<()> {
// Note that we are doing the public dial info check
// We don't have to check this for concurrency, since this routine is run in a TickTask/SingleFuture
self.inner.lock().doing_public_dial_info_check = true;
// Do the public dial info check
let out = self.do_public_dial_info_check(stop_token, l, t).await;
// Done with public dial info check
self.inner.lock().doing_public_dial_info_check = false;
self.inner.lock().needs_public_dial_info_check = false;
out
}

View File

@@ -46,7 +46,7 @@ impl Network {
NetworkUnlockedInner {
network_manager,
routing_table,
connection_manager
connection_manager,
}
}
@@ -58,7 +58,11 @@ impl Network {
Self {
config: network_manager.config(),
inner: Arc::new(Mutex::new(Self::new_inner())),
unlocked_inner: Arc::new(Self::new_unlocked_inner(network_manager, routing_table, connection_manager))
unlocked_inner: Arc::new(Self::new_unlocked_inner(
network_manager,
routing_table,
connection_manager,
)),
}
}
@@ -319,12 +323,15 @@ impl Network {
}
//////////////////////////////////////////
pub fn set_needs_public_dial_info_check(&self, _punishment: Option<Box<dyn FnOnce() + Send + 'static>>) {
pub fn set_needs_public_dial_info_check(
&self,
_punishment: Option<Box<dyn FnOnce() + Send + 'static>>,
) {
//
}
pub fn doing_public_dial_info_check(&self) -> bool {
pub fn needs_public_dial_info_check(&self) -> bool {
false
}