refactor checkpoint
This commit is contained in:
@@ -460,31 +460,6 @@ pub struct NodeInfo {
|
||||
}
|
||||
|
||||
impl NodeInfo {
|
||||
pub fn is_valid_in_routing_domain(
|
||||
&self,
|
||||
routing_table: RoutingTable,
|
||||
routing_domain: RoutingDomain,
|
||||
) -> bool {
|
||||
// Should not be passing around nodeinfo with an invalid network class
|
||||
if matches!(self.network_class, NetworkClass::Invalid) {
|
||||
return false;
|
||||
}
|
||||
// Ensure all of the dial info works in this routing domain
|
||||
for did in self.dial_info_detail_list {
|
||||
if !routing_table.ensure_dial_info_is_valid(routing_domain, &did.dial_info) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Ensure the relay is also valid in this routing domain if it is provided
|
||||
if let Some(relay_peer_info) = self.relay_peer_info {
|
||||
let relay_ni = &relay_peer_info.signed_node_info.node_info;
|
||||
if !relay_ni.is_valid_in_routing_domain(routing_table, routing_domain) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
pub fn first_filtered_dial_info_detail<F>(&self, filter: F) -> Option<DialInfoDetail>
|
||||
where
|
||||
F: Fn(&DialInfoDetail) -> bool,
|
||||
@@ -805,7 +780,7 @@ impl FromStr for SocketAddress {
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct DialInfoFilter {
|
||||
pub protocol_type_set: ProtocolTypeSet,
|
||||
pub address_type_set: AddressTypeSet,
|
||||
@@ -1449,8 +1424,8 @@ impl SignedNodeInfo {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_valid(&self) -> bool {
|
||||
self.signature.valid && self.node_info.is_valid()
|
||||
pub fn has_valid_signature(&self) -> bool {
|
||||
self.signature.valid
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user