Commit 811124a5 authored by nanamicat's avatar nanamicat

fix

parent 90631bcb
Pipeline #42449 passed with stages
in 2 minutes and 52 seconds
......@@ -77,12 +77,20 @@ impl Router {
self.addr.is_some()
}
pub fn apply_peers(&mut self, uplink: &mut Uplink) {
if uplink.peers.len() == self.peers.len() {
for (current, new) in self.peers.values_mut().zip(&mut uplink.peers) {
*current = *new
}
} else if uplink.peers.len() != 0 {
tracing::error!("router {} peers count wrong. local {} remote {}", self.id, self.peers.len(), uplink.peers.len());
}
}
pub fn on_message(&mut self, uplink: &mut Uplink, addr: SocketAddr, updating: &mut UpdatingState, now: Instant) -> Option<Downlink> {
match uplink.action {
MessageType::Query => {
for (current, new) in self.peers.values_mut().zip(&mut uplink.peers) {
*current = *new
}
self.apply_peers(uplink);
Some(Downlink {
action: MessageType::Full,
version: self.version,
......@@ -97,14 +105,11 @@ impl Router {
self.via.append(&mut uplink.via);
self.plan.append(&mut uplink.plan);
self.online(addr, now);
tracing::info!("router {} full via={:?}", self.id, self.via);
}
None
}
MessageType::Update => {
for (current, new) in self.peers.values_mut().zip(&mut uplink.peers) {
*current = *new
}
self.apply_peers(uplink);
if uplink.version == self.version {
self.online(addr, now);
if updating.router_id == self.id {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment