Inform dialing via the behaviour (#2814)

I had this change but it seems to have been lost in chaos of network upgrades.

The swarm dialing event seems to miss some cases where we dial via the behaviour. This causes an error to be logged as the peer manager doesn't know about some dialing events. 

This shifts the logic to the behaviour to inform the peer manager.
This commit is contained in:
Age Manning 2021-11-19 04:42:33 +00:00
parent 53562010ec
commit 0b319d4926
2 changed files with 5 additions and 12 deletions

View File

@ -1088,6 +1088,10 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
if let Some(event) = self.internal_events.pop_front() {
match event {
InternalBehaviourMessage::DialPeer(peer_id) => {
// For any dial event, inform the peer manager
let enr = self.discovery_mut().enr_of_peer(&peer_id);
self.peer_manager.inject_dialing(&peer_id, enr);
// Submit the event
let handler = self.new_handler();
return Poll::Ready(NBAction::Dial {
opts: DialOpts::peer_id(peer_id)

View File

@ -367,18 +367,7 @@ impl<TSpec: EthSpec> Service<TSpec> {
return Libp2pEvent::ZeroListeners;
}
}
SwarmEvent::Dialing(peer_id) => {
// We require the ENR to inject into the peer db, if it exists.
let enr = self
.swarm
.behaviour_mut()
.discovery_mut()
.enr_of_peer(&peer_id);
self.swarm
.behaviour_mut()
.peer_manager_mut()
.inject_dialing(&peer_id, enr);
}
SwarmEvent::Dialing(_peer_id) => {}
}
}
}