Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick bugfix #592

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ jobs:
- restore_cache: *restore-security-audit-cache
- run:
name: Check Security Audit
command: make security_audit
command: |
echo "Add it back when bump protobuf to `v2.6.0`."
# make security_audit
- save_cache: *save-security-audit-cache

"Check Contracts":
Expand Down
2 changes: 1 addition & 1 deletion cita-bft
37 changes: 25 additions & 12 deletions cita-network/src/node_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,12 +577,9 @@ impl AddConnectedNodeReq {
node_status.session_id = Some(*repeated_id);
node_status.score += SUCCESS_DIALING_SCORE;

let _ = service
.connected_addrs
.entry(self.session_id)
.and_modify(|v| {
v.trans_addr = Some(dialing_addr);
});
let _ = service.connected_addrs.entry(*repeated_id).and_modify(|v| {
v.trans_addr = Some(dialing_addr);
});
}
}
}
Expand Down Expand Up @@ -620,11 +617,6 @@ impl AddConnectedNodeReq {
.connected_addrs
.insert(self.session_id, TransformAddr::new(session_info.addr, None));

// Add connected peer keys
let _ = service
.connected_peer_keys
.insert(self.init_msg.peer_key, self.session_id);

// If it is an active connection, need to set this node in known_addrs has been connected.
if self.ty == SessionType::Outbound {
if let Some(ref mut node_status) =
Expand All @@ -636,6 +628,12 @@ impl AddConnectedNodeReq {
}
}

// Add connected peer keys
// Because AddRepeatedNodeReq maybe already did above action
let _ = service
.connected_peer_keys
.insert(self.init_msg.peer_key, self.session_id);

info!(
"[NodeManager] connected_addrs info: {:?}",
service.connected_addrs
Expand Down Expand Up @@ -754,8 +752,23 @@ impl AddRepeatedNodeReq {
if let Some(ref mut node_status) = service.known_addrs.get_mut(&self.addr) {
node_status.session_id = Some(self.session_id);
node_status.score += SUCCESS_DIALING_SCORE;
}

if let Some(session_info) = service.pending_connected_addrs.remove(&self.session_id) {
let _ = service.connected_addrs.insert(
self.session_id,
TransformAddr::new(session_info.addr, Some(self.addr)),
);
} else {
let _ = service
.connected_addrs
.entry(self.session_id)
.and_modify(|v| {
v.trans_addr = Some(self.addr);
});
}
} else {
warn!("[NodeManager] Cant find repeated sock addr in known addrs");
}
// This dialing is finished.
service.dialing_node = None;
}
Expand Down