mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-12-28 08:50:59 -06:00
more cleanup
This commit is contained in:
parent
630d2a53b1
commit
39eee4708c
@ -120,10 +120,11 @@ impl StorageManager {
|
|||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
);
|
);
|
||||||
|
let answer = iva.answer;
|
||||||
|
|
||||||
// Keep the descriptor if we got one. If we had a last_descriptor it will
|
// Keep the descriptor if we got one. If we had a last_descriptor it will
|
||||||
// already be validated by rpc_call_inspect_value
|
// already be validated by rpc_call_inspect_value
|
||||||
if let Some(descriptor) = iva.answer.descriptor {
|
if let Some(descriptor) = answer.descriptor {
|
||||||
let mut ctx = context.lock();
|
let mut ctx = context.lock();
|
||||||
if ctx.opt_descriptor_info.is_none() {
|
if ctx.opt_descriptor_info.is_none() {
|
||||||
let descriptor_info =
|
let descriptor_info =
|
||||||
@ -138,8 +139,8 @@ impl StorageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Keep the value if we got one and it is newer and it passes schema validation
|
// Keep the value if we got one and it is newer and it passes schema validation
|
||||||
if !iva.answer.seqs.is_empty() {
|
if !answer.seqs.is_empty() {
|
||||||
log_dht!(debug "Got seqs back: len={}", iva.answer.seqs.len());
|
log_dht!(debug "Got seqs back: len={}", answer.seqs.len());
|
||||||
let mut ctx = context.lock();
|
let mut ctx = context.lock();
|
||||||
|
|
||||||
// Ensure we have a schema and descriptor etc
|
// Ensure we have a schema and descriptor etc
|
||||||
@ -153,20 +154,19 @@ impl StorageManager {
|
|||||||
|
|
||||||
// Get number of subkeys from schema and ensure we are getting the
|
// Get number of subkeys from schema and ensure we are getting the
|
||||||
// right number of sequence numbers betwen that and what we asked for
|
// right number of sequence numbers betwen that and what we asked for
|
||||||
if iva.answer.seqs.len() != descriptor_info.subkeys.len() {
|
if answer.seqs.len() != descriptor_info.subkeys.len() {
|
||||||
// Not the right number of sequence numbers
|
// Not the right number of sequence numbers
|
||||||
// Move to the next node
|
// Move to the next node
|
||||||
return Ok(NetworkResult::invalid_message(format!(
|
return Ok(NetworkResult::invalid_message(format!(
|
||||||
"wrong number of seqs returned {} (wanted {})",
|
"wrong number of seqs returned {} (wanted {})",
|
||||||
iva.answer.seqs.len(),
|
answer.seqs.len(),
|
||||||
descriptor_info.subkeys.len()
|
descriptor_info.subkeys.len()
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a prior seqs list, merge in the new seqs
|
// If we have a prior seqs list, merge in the new seqs
|
||||||
if ctx.seqcounts.is_empty() {
|
if ctx.seqcounts.is_empty() {
|
||||||
ctx.seqcounts = iva
|
ctx.seqcounts = answer
|
||||||
.answer
|
|
||||||
.seqs
|
.seqs
|
||||||
.iter()
|
.iter()
|
||||||
.map(|s| SubkeySeqCount {
|
.map(|s| SubkeySeqCount {
|
||||||
@ -176,12 +176,12 @@ impl StorageManager {
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
} else {
|
} else {
|
||||||
if ctx.seqcounts.len() != iva.answer.seqs.len() {
|
if ctx.seqcounts.len() != answer.seqs.len() {
|
||||||
return Err(RPCError::internal(
|
return Err(RPCError::internal(
|
||||||
"seqs list length should always be equal by now",
|
"seqs list length should always be equal by now",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
for pair in ctx.seqcounts.iter_mut().zip(iva.answer.seqs.iter()) {
|
for pair in ctx.seqcounts.iter_mut().zip(answer.seqs.iter()) {
|
||||||
let ctx_seqcnt = pair.0;
|
let ctx_seqcnt = pair.0;
|
||||||
let answer_seq = *pair.1;
|
let answer_seq = *pair.1;
|
||||||
|
|
||||||
@ -212,9 +212,9 @@ impl StorageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return peers if we have some
|
// Return peers if we have some
|
||||||
log_network_result!(debug "InspectValue fanout call returned peers {}", iva.answer.peers.len());
|
log_network_result!(debug "InspectValue fanout call returned peers {}", answer.peers.len());
|
||||||
|
|
||||||
Ok(NetworkResult::value(iva.answer.peers))
|
Ok(NetworkResult::value(answer.peers))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user