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

@@ -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
}