mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-10-01 01:26:08 -04:00
fix fox nodes length issue
This commit is contained in:
parent
fe8e963af7
commit
cff955782b
@ -1054,8 +1054,8 @@ impl RoutingTableInner {
|
||||
nodes.sort_by(|a, b| compare(self, a, b));
|
||||
|
||||
// return transformed vector for filtered+sorted nodes
|
||||
let cnt = usize::min(node_count, nodes.len());
|
||||
let mut out = Vec::<O>::with_capacity(cnt);
|
||||
nodes.truncate(node_count);
|
||||
let mut out = Vec::<O>::with_capacity(nodes.len());
|
||||
for node in nodes {
|
||||
let val = transform(self, node);
|
||||
out.push(val);
|
||||
|
@ -81,7 +81,9 @@ pub struct RPCOperationFindNodeA {
|
||||
impl RPCOperationFindNodeA {
|
||||
pub fn new(peers: Vec<PeerInfo>) -> Result<Self, RPCError> {
|
||||
if peers.len() > MAX_FIND_NODE_A_PEERS_LEN {
|
||||
return Err(RPCError::protocol("find node peers length too long"));
|
||||
return Err(RPCError::protocol(
|
||||
"encoded find node peers length too long",
|
||||
));
|
||||
}
|
||||
|
||||
Ok(Self { peers })
|
||||
@ -106,7 +108,9 @@ impl RPCOperationFindNodeA {
|
||||
let peers_reader = reader.get_peers().map_err(RPCError::protocol)?;
|
||||
|
||||
if peers_reader.len() as usize > MAX_FIND_NODE_A_PEERS_LEN {
|
||||
return Err(RPCError::protocol("find node peers length too long"));
|
||||
return Err(RPCError::protocol(
|
||||
"decoded find node peers length too long",
|
||||
));
|
||||
}
|
||||
|
||||
let mut peers = Vec::<PeerInfo>::with_capacity(
|
||||
|
@ -89,7 +89,9 @@ impl RPCOperationGetValueA {
|
||||
descriptor: Option<SignedValueDescriptor>,
|
||||
) -> Result<Self, RPCError> {
|
||||
if peers.len() > MAX_GET_VALUE_A_PEERS_LEN {
|
||||
return Err(RPCError::protocol("GetValueA peers length too long"));
|
||||
return Err(RPCError::protocol(
|
||||
"encoded GetValueA peers length too long",
|
||||
));
|
||||
}
|
||||
Ok(Self {
|
||||
value,
|
||||
@ -175,7 +177,9 @@ impl RPCOperationGetValueA {
|
||||
|
||||
let peers_reader = reader.get_peers().map_err(RPCError::protocol)?;
|
||||
if peers_reader.len() as usize > MAX_GET_VALUE_A_PEERS_LEN {
|
||||
return Err(RPCError::protocol("GetValueA peers length too long"));
|
||||
return Err(RPCError::protocol(
|
||||
"decoded GetValueA peers length too long",
|
||||
));
|
||||
}
|
||||
let mut peers = Vec::<PeerInfo>::with_capacity(
|
||||
peers_reader
|
||||
|
@ -123,7 +123,9 @@ impl RPCOperationSetValueA {
|
||||
peers: Vec<PeerInfo>,
|
||||
) -> Result<Self, RPCError> {
|
||||
if peers.len() as usize > MAX_SET_VALUE_A_PEERS_LEN {
|
||||
return Err(RPCError::protocol("SetValueA peers length too long"));
|
||||
return Err(RPCError::protocol(
|
||||
"encoded SetValueA peers length too long",
|
||||
));
|
||||
}
|
||||
Ok(Self { set, value, peers })
|
||||
}
|
||||
@ -182,7 +184,9 @@ impl RPCOperationSetValueA {
|
||||
};
|
||||
let peers_reader = reader.get_peers().map_err(RPCError::protocol)?;
|
||||
if peers_reader.len() as usize > MAX_SET_VALUE_A_PEERS_LEN {
|
||||
return Err(RPCError::protocol("SetValueA peers length too long"));
|
||||
return Err(RPCError::protocol(
|
||||
"decoded SetValueA peers length too long",
|
||||
));
|
||||
}
|
||||
let mut peers = Vec::<PeerInfo>::with_capacity(
|
||||
peers_reader
|
||||
|
Loading…
Reference in New Issue
Block a user