mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 02:12:33 +00:00
Remove network lock (#840)
* Initial work on removing libp2p lock * Removes lock from libp2p service * Completed network lock removal * Correct network termination future * Correct fmt issues * Remove Drop implementation for network service * Address reviewers suggestions * Fix dht persistence test (#844) * Fix persistence test * Block until dht is persisted * Fix libp2p test * Correct test ordering check * Remove expensive tests from debug testing Co-authored-by: Pawan Dhananjay <pawandhananjay@gmail.com>
This commit is contained in:
@@ -58,6 +58,6 @@ impl<T: BeaconChainTypes> Client<T> {
|
||||
|
||||
/// Returns the local libp2p ENR of this node, for network discovery.
|
||||
pub fn enr(&self) -> Option<Enr> {
|
||||
self.libp2p_network.as_ref().map(|n| n.local_enr())
|
||||
self.libp2p_network.as_ref()?.local_enr()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,6 @@ const DAYS_PER_WEEK: f64 = 7.0;
|
||||
const HOURS_PER_DAY: f64 = 24.0;
|
||||
const MINUTES_PER_HOUR: f64 = 60.0;
|
||||
|
||||
/// How long to wait for the lock on `network.libp2p_service()` before we give up.
|
||||
const LIBP2P_LOCK_TIMEOUT: Duration = Duration::from_millis(50);
|
||||
|
||||
/// The number of historical observations that should be used to determine the average sync time.
|
||||
const SPEEDO_OBSERVATIONS: usize = 4;
|
||||
|
||||
@@ -60,15 +57,7 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
|
||||
.for_each(move |_| {
|
||||
let log = log_2.clone();
|
||||
|
||||
let connected_peer_count = if let Some(libp2p) = network
|
||||
.libp2p_service()
|
||||
.try_lock_until(Instant::now() + LIBP2P_LOCK_TIMEOUT)
|
||||
{
|
||||
libp2p.swarm.connected_peers()
|
||||
} else {
|
||||
// Use max_value here and we'll print something pretty later.
|
||||
usize::max_value()
|
||||
};
|
||||
let connected_peer_count = network.connected_peers();
|
||||
|
||||
let head_info = beacon_chain.head_info()
|
||||
.map_err(|e| error!(
|
||||
|
||||
Reference in New Issue
Block a user