-
Notifications
You must be signed in to change notification settings - Fork 56
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
chore: always specify the quoting metric explicitly #2566
base: main
Are you sure you want to change the base?
chore: always specify the quoting metric explicitly #2566
Conversation
c33b061
to
c0d1934
Compare
c0d1934
to
4d9ac69
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice tweaks, but I'm not sure about the Option
addition in the quoting metrics
@@ -103,7 +103,7 @@ pub enum LocalSwarmCmd { | |||
/// Returns the quoting metrics and whether the record at `key` is already stored locally | |||
GetLocalQuotingMetrics { | |||
key: RecordKey, | |||
sender: oneshot::Sender<(QuotingMetrics, bool)>, | |||
sender: oneshot::Sender<Option<(QuotingMetrics, bool)>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why return an option here?
@@ -775,7 +775,7 @@ impl Network { | |||
pub async fn get_local_quoting_metrics( | |||
&self, | |||
key: RecordKey, | |||
) -> Result<(QuotingMetrics, bool)> { | |||
) -> Result<Option<(QuotingMetrics, bool)>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does None mean in this case? I think Result<Option<_>>
is a confusing pattern
@@ -117,13 +117,13 @@ impl UnifiedRecordStore { | |||
&self, | |||
key: &RecordKey, | |||
network_size: Option<u64>, | |||
) -> (QuotingMetrics, bool) { | |||
) -> Option<(QuotingMetrics, bool)> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we use Option
here?
Ok(None) => { | ||
error!("Quoting metrics not found for {key:?}. This might be because we are using a ClientRecordStore??. This should not happen"); | ||
QueryResponse::GetStoreQuote { | ||
quote: Err(ProtocolError::GetStoreQuoteFailed), | ||
peer_address: NetworkAddress::from_peer(self_id), | ||
storage_proofs, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would getting rid of this Option
type solve the issue of the "This should not happen"
error here?
No description provided.