Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Igor Aleksanov <[email protected]>
  • Loading branch information
StanislavBreadless and popzxc authored Dec 7, 2021
1 parent 2aa2ee2 commit 745302c
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use super::types::RequestMetadata;

const CLOUDFLARE_CONNECTING_IP_HEADER: &str = "CF-Connecting-IP";

///
/// Unfortunately, the JSON-RPC library does not natively support retrieving any information about the HTTP request,
///
/// But since the logic of subsidies relies on IP of the sender, we need to somehow extract the ip of the user from `CF-Connecting-IP`
Expand All @@ -20,10 +19,11 @@ const CLOUDFLARE_CONNECTING_IP_HEADER: &str = "CF-Connecting-IP";
/// parameter of the JSON-RPC call.
pub struct IpInsertMiddleWare {}

/// Struct which is used to describe the minimum number of parameters and the maximum number of parameters for a single JSON-RPC method
/// Structure that is used to describe the minimum and the maximum number
/// of parameters for a single JSON-RPC method.
struct MethodWithIpDescription {
minimum_params: usize,
// the last one is always the ip parameter
// The last one is always the IP parameter.
maximum_params: usize,
}

Expand All @@ -36,7 +36,7 @@ impl MethodWithIpDescription {
}
}

/// Get the original JSON-RPC MethodCall object and the IP of the user.
/// Gets the original JSON-RPC `MethodCall` object and the IP of the user.
/// If the method does not need the information about the IP of the user, simply returns the supplied call.
/// If the method should have information about the IP appended to its parameters, it returns the new call
/// which is identical to the supplied one, but with the IP appended.
Expand Down Expand Up @@ -75,7 +75,7 @@ fn get_call_with_ip_if_needed(
return new_call;
}

// If the length is equsl to the maximum amount of the
// If the length is equal to the maximum amount of the
// maximum_params, then the user tried to override ip
if params.len() == description.maximum_params {
params.pop();
Expand Down

0 comments on commit 745302c

Please sign in to comment.