Skip to content

Feaure privacy range order#97

Merged
grunch merged 2 commits into
developfrom
feaure-privacy-range-order
Mar 31, 2025
Merged

Feaure privacy range order#97
grunch merged 2 commits into
developfrom
feaure-privacy-range-order

Conversation

@arkanoider

@arkanoider arkanoider commented Mar 31, 2025

Copy link
Copy Markdown
Collaborator

@grunch @Catrya ,

I moved the check for full privacy orders in mostro-core to use it directly as order method and improved SolverDisputeInfo to have optional fields in case of full privacy orders.

Summary by CodeRabbit

  • New Features
    • Enhanced how dispute information is presented by grouping key user details such as ratings, reviews, and operational periods with integrated privacy handling.
    • Introduced a new check on orders to clearly indicate full privacy status for both buyers and sellers.

@coderabbitai

coderabbitai Bot commented Mar 31, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The pull request restructures how dispute information is handled by introducing a new UserDisputeInfo struct. The changes refactor the SolverDisputeInfo struct by removing several individual user-related fields and replacing them with encapsulated optional user info fields. The constructor method is updated to accept optional user data and conditionally populate these fields based on privacy mode checks. Additionally, a new method is added to the Order struct to determine full privacy status for both buyers and sellers based on their public key comparisons.

Changes

File Summary
src/dispute.rs - Added new UserDisputeInfo struct.
- Modified SolverDisputeInfo: removed individual user fields and added initiator_info and counterpart_info as Option<UserDisputeInfo>.
- Updated new to accept Option<User> and perform privacy mode checks.
src/order.rs - Added public method is_full_privacy_order which returns a tuple indicating the full privacy status of both buyer and seller by comparing public keys with master keys.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant S as SolverDisputeInfo::new
    participant U as User Data
    C->>S: Call new(Option<User> initiator, Option<User> counterpart)
    alt Initiator not in privacy mode
        S->>U: Retrieve initiator data (rating, reviews, created_at)
        S->>S: Create UserDisputeInfo for initiator
    else Initiator in privacy mode
        S->>S: Set initiator_info to None
    end
    alt Counterpart not in privacy mode
        S->>U: Retrieve counterpart data (rating, reviews, created_at)
        S->>S: Create UserDisputeInfo for counterpart
    else Counterpart in privacy mode
        S->>S: Set counterpart_info to None
    end
    S-->>C: Return SolverDisputeInfo instance
Loading
sequenceDiagram
    participant C as Client
    participant O as Order::is_full_privacy_order
    participant B as Buyer Data
    participant S as Seller Data
    C->>O: Call is_full_privacy_order()
    O->>B: Check buyer public key vs master key
    O->>S: Check seller public key vs master key
    O-->>C: Return (buyer_privacy, seller_privacy)
Loading

Possibly related PRs

Suggested reviewers

  • grunch
  • Catrya

Poem

I'm a rabbit hopping with glee,
In code fields where changes run free.
Structs now hold what once was split,
Privacy checks finely knit.
Hop along with these lines, it's all acme!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/order.rs (1)

343-363: Implementation looks good but documentation could be clearer

The new method is_full_privacy_order correctly checks if buyers and sellers are using their master public keys directly, which indicates full privacy mode. This aligns well with the PR objective of relocating the full privacy check.

However, there's a minor grammatical issue in the documentation comment.

-/// check if a user is creating a full privacy order so he doesn't to have reputation
+/// Check if users are operating in full privacy mode (using master public keys directly)
+/// Returns a tuple of (buyer_privacy_status, seller_privacy_status)
src/dispute.rs (2)

74-80: Remove extra blank line in struct declaration

The new UserDisputeInfo struct looks good but has an unnecessary blank line between the derive attribute and struct declaration.

#[derive(Debug, Default, Deserialize, Serialize, Clone)]
-
pub struct UserDisputeInfo {
    pub rating: f64,
    pub reviews: i64,
    pub operating_days: u64,
}

118-144: Fix typo in variable name

The implementation correctly handles optional user information and calculates operating days properly. However, there's a typo in the variable name.

if let Some(counterpart) = counterpart {
    let now = Timestamp::now();
-    let couterpart_operating_days = (now.as_u64() - counterpart.created_at as u64) / 86400;
+    let counterpart_operating_days = (now.as_u64() - counterpart.created_at as u64) / 86400;
    counterpart_info = Some(UserDisputeInfo {
        rating: counterpart.total_rating,
        reviews: counterpart.total_reviews,
-        operating_days: couterpart_operating_days,
+        operating_days: counterpart_operating_days,
    });
    counterpart_full_privacy = false;
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec71afe and 0fd74fc.

📒 Files selected for processing (2)
  • src/dispute.rs (5 hunks)
  • src/order.rs (1 hunks)
🔇 Additional comments (3)
src/dispute.rs (3)

94-97: LGTM - Good encapsulation of privacy-related fields

These new fields properly support the full privacy functionality by tracking both privacy status and conditionally including user information. This is more maintainable than individual fields.


115-116: Good change to support optional user information

Making the user parameters optional aligns with the full privacy functionality, allowing the method to handle cases where user information might not be available.


156-159: LGTM - Proper initialization of new fields

The fields are initialized correctly based on the values calculated earlier in the method.

@Catrya Catrya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK

@grunch grunch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@grunch grunch merged commit 436f3f9 into develop Mar 31, 2025
@grunch grunch deleted the feaure-privacy-range-order branch March 31, 2025 20:59
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.

3 participants