-
Notifications
You must be signed in to change notification settings - Fork 9
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
Fix: sends right index on first operation #110
Conversation
WalkthroughThe pull request introduces modifications to several files in the CLI and database modules, focusing on the trade index handling mechanism. The primary change involves adjusting how the last trade index is set and retrieved across multiple functions. The modifications aim to address an issue with trade key generation, specifically how the initial trade index is handled when creating or taking orders. Changes
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/cli.rs (1)
310-310
: Improve error handling for invalid Mostro pubkey
If an invalid pubkey is provided, it might be beneficial to include the offendingpubkey
in the error message so the user can quickly identify the issue.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
src/cli.rs
(1 hunks)src/cli/get_dm.rs
(1 hunks)src/cli/new_order.rs
(1 hunks)src/cli/send_msg.rs
(1 hunks)src/cli/take_buy.rs
(1 hunks)src/cli/take_sell.rs
(1 hunks)src/db.rs
(1 hunks)
🔇 Additional comments (6)
src/cli/take_buy.rs (1)
98-98
: Confirm the correctness of no-increment logic.Previously, the code incremented the trade index by 1. Now, it simply sets the last trade index to the current
trade_index
. Ensure that any logic in the codebase expecting this index to be bumped up (e.g., if referencing the "next" trade index) is properly updated.Would you like me to generate a shell script to locate other references to the user’s last trade index usage and check for potential off-by-one errors?
src/cli/take_sell.rs (1)
120-120
: Maintain consistency in trade index usage.This change removes the increment step from the last trade index updating logic. Verify that this aligns with the rest of the system, particularly if there are any calculations downstream that rely on the index being incremented after each trade.
src/cli/send_msg.rs (1)
105-105
: Ensure the updated index logic matches order creation flow.The index is directly assigned to
trade_index
instead of incrementing it. Confirm that no other workflow stage (e.g., new order creation or invoice generation) expects an incremented trade index.src/cli/get_dm.rs (1)
88-88
: Validate index continuity across new orders.When creating a new DB order, the code sets the last trade index to the current
trade_index
. Check if the rest of the order management logic, especially in the “new order” scenario, is consistent with not incrementing the index.src/cli/new_order.rs (1)
185-185
: Ensure concurrency safety for last_trade_index updates
If multiple orders are created in parallel, there's a risk that the same trade index could be assigned to separate orders. Consider using transactions or other concurrency-control mechanisms (e.g., row-level locks or optimistic concurrency checks) to avoid conflicts.src/db.rs (1)
173-173
: Consistent trade index usage
This direct assignment totrade_index
aligns with your updated approach of not decrementing the value. Glad to see the consistency with other modules.
Fix #109
Summary by CodeRabbit
Release Notes
Bug Fixes
Refactor
Chores