feat: get_all_completed_transactions bitflag status filtering#7161
Conversation
WalkthroughA new optional Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant gRPC_Server
participant TransactionStore
Client->>gRPC_Server: GetAllCompletedTransactionsRequest(status_bitflag)
gRPC_Server->>TransactionStore: Fetch all completed transactions
TransactionStore-->>gRPC_Server: Return transaction list
gRPC_Server->>gRPC_Server: Filter transactions by status_bitflag
gRPC_Server-->>Client: Return filtered transactions
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (7)
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
applications/minotari_app_grpc/proto/wallet.proto (1)
1427-1431: Add documentation for thestatus_bitflagfieldInclude a comment above the new field to explain its purpose and default behavior:
message GetAllCompletedTransactionsRequest { uint64 offset = 1; uint64 limit = 2; - uint32 status_bitflag = 3; + // Optional bitmask to filter returned transactions by their status flags. + // If zero (default or omitted), all completed transactions are returned; + // otherwise, only transactions for which (status & status_bitflag) != 0 are included. + uint32 status_bitflag = 3; }applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs (1)
1205-1205: Optimize the bitflag filtering implementation and add validation.The bitflag filtering logic is correct, but there are several improvements that can be made:
- Remove the unnecessary
.clone()call ontx.statussince enum-to-u32 casting doesn't require cloning- Add validation for the
status_bitflagvalue to prevent potential overflow- Add documentation to explain the bitflag filtering logic
Apply this diff to optimize and improve the implementation:
- .filter(|tx| req.status_bitflag == 0 || (req.status_bitflag & (1 << (tx.status.clone() as u32))) != 0) + .filter(|tx| { + // If status_bitflag is 0, return all transactions (no filtering) + // Otherwise, check if the transaction's status bit is set in the bitflag + req.status_bitflag == 0 || (req.status_bitflag & (1 << (tx.status as u32))) != 0 + })Additionally, consider adding validation near the beginning of the method to ensure the bitflag value is reasonable:
// Validate status_bitflag to prevent potential overflow (assuming status enum has < 32 variants) if req.status_bitflag != 0 && req.status_bitflag >= (1 << 32) { return Err(Status::invalid_argument("status_bitflag value is too large")); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
applications/minotari_app_grpc/proto/wallet.proto(1 hunks)applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: test (mainnet, stagenet)
- GitHub Check: test (nextnet, nextnet)
- GitHub Check: cargo check with stable
Test Results (CI)371 tests 370 ✅ 7m 39s ⏱️ For more details on these failures, see this check. Results for commit 0a0af9f. |
use uint64
Description --- For some reason it was removed while merging. Origin: #7161 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added the ability to filter completed transactions by status when viewing transaction history. - **Enhancements** - Improved transaction history pagination to work with filtered results. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Description
Motivation and Context
How Has This Been Tested?
locally, using nodejs client:
What process can a PR reviewer use to test or verify this change?
Breaking Changes
Summary by CodeRabbit