From 7c6a3f0e8a97c5ddd0aa3e9d2bed8cad707fe53d Mon Sep 17 00:00:00 2001 From: Brice Dobry Date: Thu, 25 Apr 2024 11:56:05 -0400 Subject: [PATCH] chore: make `HttpRequest` impls more consistent Rearrange the methods to be in the same order, and change some parameter names to be more consistent. --- stackslib/src/net/api/getblock.rs | 2 +- stackslib/src/net/api/getblock_v3.rs | 8 ++++---- stackslib/src/net/api/getmicroblocks_confirmed.rs | 2 +- stackslib/src/net/api/getmicroblocks_indexed.rs | 2 +- stackslib/src/net/api/getmicroblocks_unconfirmed.rs | 2 +- stackslib/src/net/api/getstackers.rs | 8 ++++---- stackslib/src/net/api/gettenure.rs | 8 ++++---- stackslib/src/net/api/gettenureinfo.rs | 8 ++++---- stackslib/src/net/api/postblock_proposal.rs | 8 ++++---- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/stackslib/src/net/api/getblock.rs b/stackslib/src/net/api/getblock.rs index 7d6c1bba09..4bb55fad28 100644 --- a/stackslib/src/net/api/getblock.rs +++ b/stackslib/src/net/api/getblock.rs @@ -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. diff --git a/stackslib/src/net/api/getblock_v3.rs b/stackslib/src/net/api/getblock_v3.rs index 19d38f5ba3..0279d9dc0c 100644 --- a/stackslib/src/net/api/getblock_v3.rs +++ b/stackslib/src/net/api/getblock_v3.rs @@ -126,6 +126,10 @@ impl HttpRequest for RPCNakamotoBlockRequestHandler { Regex::new(r#"^/v3/blocks/(?P[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( @@ -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 { diff --git a/stackslib/src/net/api/getmicroblocks_confirmed.rs b/stackslib/src/net/api/getmicroblocks_confirmed.rs index 3aafe6e2de..d4987c9909 100644 --- a/stackslib/src/net/api/getmicroblocks_confirmed.rs +++ b/stackslib/src/net/api/getmicroblocks_confirmed.rs @@ -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. diff --git a/stackslib/src/net/api/getmicroblocks_indexed.rs b/stackslib/src/net/api/getmicroblocks_indexed.rs index 3900d2f3cb..43a3a73e04 100644 --- a/stackslib/src/net/api/getmicroblocks_indexed.rs +++ b/stackslib/src/net/api/getmicroblocks_indexed.rs @@ -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. diff --git a/stackslib/src/net/api/getmicroblocks_unconfirmed.rs b/stackslib/src/net/api/getmicroblocks_unconfirmed.rs index dd4d45f1c7..41d0b77681 100644 --- a/stackslib/src/net/api/getmicroblocks_unconfirmed.rs +++ b/stackslib/src/net/api/getmicroblocks_unconfirmed.rs @@ -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. diff --git a/stackslib/src/net/api/getstackers.rs b/stackslib/src/net/api/getstackers.rs index e6b9611191..4546b66fc9 100644 --- a/stackslib/src/net/api/getstackers.rs +++ b/stackslib/src/net/api/getstackers.rs @@ -99,6 +99,10 @@ impl HttpRequest for GetStackersRequestHandler { Regex::new(r#"^/v2/stacker_set/(?P[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( @@ -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 { diff --git a/stackslib/src/net/api/gettenure.rs b/stackslib/src/net/api/gettenure.rs index bc0a058f6e..c3eb4493fe 100644 --- a/stackslib/src/net/api/gettenure.rs +++ b/stackslib/src/net/api/gettenure.rs @@ -155,6 +155,10 @@ impl HttpRequest for RPCNakamotoTenureRequestHandler { Regex::new(r#"^/v3/tenures/(?P[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( @@ -195,10 +199,6 @@ impl HttpRequest for RPCNakamotoTenureRequestHandler { Ok(req_contents) } - - fn metrics_identifier(&self) -> &str { - "/v3/tenures/:block_id" - } } impl RPCRequestHandler for RPCNakamotoTenureRequestHandler { diff --git a/stackslib/src/net/api/gettenureinfo.rs b/stackslib/src/net/api/gettenureinfo.rs index d79011903b..e03b6317f4 100644 --- a/stackslib/src/net/api/gettenureinfo.rs +++ b/stackslib/src/net/api/gettenureinfo.rs @@ -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( @@ -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 { diff --git a/stackslib/src/net/api/postblock_proposal.rs b/stackslib/src/net/api/postblock_proposal.rs index dad1b9a1dd..b804af0576 100644 --- a/stackslib/src/net/api/postblock_proposal.rs +++ b/stackslib/src/net/api/postblock_proposal.rs @@ -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( @@ -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 {