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

[r2r] Allow bestorders RPC execution with number #1327

Merged
merged 8 commits into from
Jul 4, 2022

Conversation

laruh
Copy link
Member

@laruh laruh commented Jun 27, 2022

Implementation of the code to solve the problem "Allow bestorders RPC execution without volume argument" #1314

Changes have been made:
1.best_orders.rs
Function process_best_orders_p2p_request_by_number was added
In fn best_orders_rpc_v2 instead of req: BestOrdersRequest there is req: BestOrdersRequestV2

2.lp_ordermatch.rs
OrdermatchRequest::BestOrdersByNumber was added, it is matched in function process_peer_request, result goes into the function best_orders::process_best_orders_p2p_request_by_number

3.tests added in best_orders_tests

@laruh laruh requested a review from artemii235 June 27, 2022 07:48
@laruh laruh changed the title [wip] Allow bestorders RPC execution with number [r2r] Allow bestorders RPC execution with number Jun 27, 2022
Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

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

Good work! I have only one note for now :)

mm2src/mm2_main/src/lp_ordermatch/best_orders.rs Outdated Show resolved Hide resolved
yurii-khi
yurii-khi previously approved these changes Jun 29, 2022
Copy link

@yurii-khi yurii-khi left a comment

Choose a reason for hiding this comment

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

Thanks @laruh for prompt fixes!
If I understand correctly from code, second approach, mentioned here #1314 (comment) was implemented eventually?

@laruh
Copy link
Member Author

laruh commented Jun 29, 2022

Thanks @laruh for prompt fixes! If I understand correctly from code, second approach, mentioned here #1314 (comment) was implemented eventually?

Hi!
That is correct. Currently program in bestorders_by_number branch implements the second variant of request

{
        "userpass": mm_alice.userpass,
        "method": "best_orders",
        "mmrpc": "2.0",
        "params": {
            "coin": "RICK",
            "action": "buy",
            "request_by": {
                "type": "number",
                "value": 1
            }
        }
    }

@artemii235
Copy link
Member

@ozkanonur Could you take a look too, please? 🙂

Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

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

LGTM. Great work 🔥

Only one note. In the codeblocks, I suggest you to not create permament mutable variables to avoid future bugs or unexpected issues behaviour. I prefer to create mut variables as temporary by shadowing them as immutable right after where I no longer need to update them.

An example:

@@ -191,6 +191,12 @@ pub fn process_best_orders_p2p_request_by_number(
             BestOrdersAction::Sell => result.insert(pair.0, best_orders),
         };
     }
+
+    // Drop mutability of result, protocol_infos and conf_infos
+    let result = result;
+    let protocol_infos = protocol_infos;
+    let conf_infos = conf_infos;
+
     let response = BestOrdersP2PRes {
         orders: result,
         protocol_infos,

@laruh
Copy link
Member Author

laruh commented Jul 1, 2022

LGTM. Great work fire

Only one note. In the codeblocks, I suggest you to not create permament mutable variables to avoid future bugs or unexpected issues behaviour. I prefer to create mut variables as temporary by shadowing them as immutable right after where I no longer need to update them.

An example:

@@ -191,6 +191,12 @@ pub fn process_best_orders_p2p_request_by_number(
             BestOrdersAction::Sell => result.insert(pair.0, best_orders),
         };
     }
+
+    // Drop mutability of result, protocol_infos and conf_infos
+    let result = result;
+    let protocol_infos = protocol_infos;
+    let conf_infos = conf_infos;
+
     let response = BestOrdersP2PRes {
         orders: result,
         protocol_infos,

Good idea! Done

Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

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

🔥

Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

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

👍

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.

4 participants