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

chore: always specify the quoting metric explicitly #2566

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RolandSherwin
Copy link
Member

No description provided.

@RolandSherwin RolandSherwin force-pushed the dont_return_empty_quotess branch from c33b061 to c0d1934 Compare December 23, 2024 11:22
@RolandSherwin RolandSherwin changed the title chore: always specify the metric explicitly chore: always specify the quoting metric explicitly Dec 23, 2024
@RolandSherwin RolandSherwin force-pushed the dont_return_empty_quotess branch from c0d1934 to 4d9ac69 Compare December 23, 2024 11:23
Copy link
Member

@grumbach grumbach left a 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)>>,
Copy link
Member

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)>> {
Copy link
Member

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)> {
Copy link
Member

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?

Comment on lines +621 to +628
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,
}
}
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants