Skip to content

Commit

Permalink
chore: make HttpRequest impls more consistent
Browse files Browse the repository at this point in the history
Rearrange the methods to be in the same order, and change some
parameter names to be more consistent.
  • Loading branch information
obycode committed Apr 25, 2024
1 parent 89c5441 commit 7c6a3f0
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion stackslib/src/net/api/getblock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl HttpRequest for RPCBlocksRequestHandler {
}

fn metrics_identifier(&self) -> &str {
"/v2/blocks/:hash"
"/v2/blocks/:block_id"
}

/// Try to decode this request.
Expand Down
8 changes: 4 additions & 4 deletions stackslib/src/net/api/getblock_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ impl HttpRequest for RPCNakamotoBlockRequestHandler {
Regex::new(r#"^/v3/blocks/(?P<block_id>[0-9a-f]{64})$"#).unwrap()
}

fn metrics_identifier(&self) -> &str {
"/v3/blocks/:block_id"
}

/// Try to decode this request.
/// There's nothing to load here, so just make sure the request is well-formed.
fn try_parse_request(
Expand Down Expand Up @@ -155,10 +159,6 @@ impl HttpRequest for RPCNakamotoBlockRequestHandler {

Ok(HttpRequestContents::new().query_string(query))
}

fn metrics_identifier(&self) -> &str {
"/v3/blocks/:block_id"
}
}

impl RPCRequestHandler for RPCNakamotoBlockRequestHandler {
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/net/api/getmicroblocks_confirmed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl HttpRequest for RPCMicroblocksConfirmedRequestHandler {
}

fn metrics_identifier(&self) -> &str {
"/v2/microblocks/confirmed/:hash"
"/v2/microblocks/confirmed/:block_id"
}

/// Try to decode this request.
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/net/api/getmicroblocks_indexed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl HttpRequest for RPCMicroblocksIndexedRequestHandler {
}

fn metrics_identifier(&self) -> &str {
"/v2/microblocks/:hash"
"/v2/microblocks/:microblock_id"
}

/// Try to decode this request.
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/net/api/getmicroblocks_unconfirmed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl HttpRequest for RPCMicroblocksUnconfirmedRequestHandler {
}

fn metrics_identifier(&self) -> &str {
"/v2/microblocks/unconfirmed/:hash/:seq"
"/v2/microblocks/unconfirmed/:block_id/:seq"
}

/// Try to decode this request.
Expand Down
8 changes: 4 additions & 4 deletions stackslib/src/net/api/getstackers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ impl HttpRequest for GetStackersRequestHandler {
Regex::new(r#"^/v2/stacker_set/(?P<cycle_num>[0-9]{1,20})$"#).unwrap()
}

fn metrics_identifier(&self) -> &str {
"/v2/stacker_set/:cycle_num"
}

/// Try to decode this request.
/// There's nothing to load here, so just make sure the request is well-formed.
fn try_parse_request(
Expand Down Expand Up @@ -126,10 +130,6 @@ impl HttpRequest for GetStackersRequestHandler {

Ok(HttpRequestContents::new().query_string(query))
}

fn metrics_identifier(&self) -> &str {
"/v2/stacker_set/:cycle_num"
}
}

impl RPCRequestHandler for GetStackersRequestHandler {
Expand Down
8 changes: 4 additions & 4 deletions stackslib/src/net/api/gettenure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ impl HttpRequest for RPCNakamotoTenureRequestHandler {
Regex::new(r#"^/v3/tenures/(?P<block_id>[0-9a-f]{64})$"#).unwrap()
}

fn metrics_identifier(&self) -> &str {
"/v3/tenures/:block_id"
}

/// Try to decode this request.
/// There's nothing to load here, so just make sure the request is well-formed.
fn try_parse_request(
Expand Down Expand Up @@ -195,10 +199,6 @@ impl HttpRequest for RPCNakamotoTenureRequestHandler {

Ok(req_contents)
}

fn metrics_identifier(&self) -> &str {
"/v3/tenures/:block_id"
}
}

impl RPCRequestHandler for RPCNakamotoTenureRequestHandler {
Expand Down
8 changes: 4 additions & 4 deletions stackslib/src/net/api/gettenureinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ impl HttpRequest for RPCNakamotoTenureInfoRequestHandler {
Regex::new(r#"^/v3/tenures/info"#).unwrap()
}

fn metrics_identifier(&self) -> &str {
"/v3/tenures/info"
}

/// Try to decode this request.
/// There's nothing to load here, so just make sure the request is well-formed.
fn try_parse_request(
Expand All @@ -97,10 +101,6 @@ impl HttpRequest for RPCNakamotoTenureInfoRequestHandler {
}
Ok(HttpRequestContents::new().query_string(query))
}

fn metrics_identifier(&self) -> &str {
"/v3/tenures/info"
}
}

impl RPCRequestHandler for RPCNakamotoTenureInfoRequestHandler {
Expand Down
8 changes: 4 additions & 4 deletions stackslib/src/net/api/postblock_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ impl HttpRequest for RPCBlockProposalRequestHandler {
Regex::new(r#"^/v2/block_proposal$"#).unwrap()
}

fn metrics_identifier(&self) -> &str {
"/v2/block_proposal"
}

/// Try to decode this request.
/// There's nothing to load here, so just make sure the request is well-formed.
fn try_parse_request(
Expand Down Expand Up @@ -424,10 +428,6 @@ impl HttpRequest for RPCBlockProposalRequestHandler {
self.block_proposal = Some(block_proposal);
Ok(HttpRequestContents::new().query_string(query))
}

fn metrics_identifier(&self) -> &str {
"/v2/block_proposal"
}
}

struct ProposalThreadInfo {
Expand Down

0 comments on commit 7c6a3f0

Please sign in to comment.