Skip to content

Commit 7c6a3f0

Browse files
committed
chore: make HttpRequest impls more consistent
Rearrange the methods to be in the same order, and change some parameter names to be more consistent.
1 parent 89c5441 commit 7c6a3f0

9 files changed

+24
-24
lines changed

stackslib/src/net/api/getblock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl HttpRequest for RPCBlocksRequestHandler {
9191
}
9292

9393
fn metrics_identifier(&self) -> &str {
94-
"/v2/blocks/:hash"
94+
"/v2/blocks/:block_id"
9595
}
9696

9797
/// Try to decode this request.

stackslib/src/net/api/getblock_v3.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ impl HttpRequest for RPCNakamotoBlockRequestHandler {
126126
Regex::new(r#"^/v3/blocks/(?P<block_id>[0-9a-f]{64})$"#).unwrap()
127127
}
128128

129+
fn metrics_identifier(&self) -> &str {
130+
"/v3/blocks/:block_id"
131+
}
132+
129133
/// Try to decode this request.
130134
/// There's nothing to load here, so just make sure the request is well-formed.
131135
fn try_parse_request(
@@ -155,10 +159,6 @@ impl HttpRequest for RPCNakamotoBlockRequestHandler {
155159

156160
Ok(HttpRequestContents::new().query_string(query))
157161
}
158-
159-
fn metrics_identifier(&self) -> &str {
160-
"/v3/blocks/:block_id"
161-
}
162162
}
163163

164164
impl RPCRequestHandler for RPCNakamotoBlockRequestHandler {

stackslib/src/net/api/getmicroblocks_confirmed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl HttpRequest for RPCMicroblocksConfirmedRequestHandler {
8080
}
8181

8282
fn metrics_identifier(&self) -> &str {
83-
"/v2/microblocks/confirmed/:hash"
83+
"/v2/microblocks/confirmed/:block_id"
8484
}
8585

8686
/// Try to decode this request.

stackslib/src/net/api/getmicroblocks_indexed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl HttpRequest for RPCMicroblocksIndexedRequestHandler {
113113
}
114114

115115
fn metrics_identifier(&self) -> &str {
116-
"/v2/microblocks/:hash"
116+
"/v2/microblocks/:microblock_id"
117117
}
118118

119119
/// Try to decode this request.

stackslib/src/net/api/getmicroblocks_unconfirmed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl HttpRequest for RPCMicroblocksUnconfirmedRequestHandler {
107107
}
108108

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

113113
/// Try to decode this request.

stackslib/src/net/api/getstackers.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ impl HttpRequest for GetStackersRequestHandler {
9999
Regex::new(r#"^/v2/stacker_set/(?P<cycle_num>[0-9]{1,20})$"#).unwrap()
100100
}
101101

102+
fn metrics_identifier(&self) -> &str {
103+
"/v2/stacker_set/:cycle_num"
104+
}
105+
102106
/// Try to decode this request.
103107
/// There's nothing to load here, so just make sure the request is well-formed.
104108
fn try_parse_request(
@@ -126,10 +130,6 @@ impl HttpRequest for GetStackersRequestHandler {
126130

127131
Ok(HttpRequestContents::new().query_string(query))
128132
}
129-
130-
fn metrics_identifier(&self) -> &str {
131-
"/v2/stacker_set/:cycle_num"
132-
}
133133
}
134134

135135
impl RPCRequestHandler for GetStackersRequestHandler {

stackslib/src/net/api/gettenure.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ impl HttpRequest for RPCNakamotoTenureRequestHandler {
155155
Regex::new(r#"^/v3/tenures/(?P<block_id>[0-9a-f]{64})$"#).unwrap()
156156
}
157157

158+
fn metrics_identifier(&self) -> &str {
159+
"/v3/tenures/:block_id"
160+
}
161+
158162
/// Try to decode this request.
159163
/// There's nothing to load here, so just make sure the request is well-formed.
160164
fn try_parse_request(
@@ -195,10 +199,6 @@ impl HttpRequest for RPCNakamotoTenureRequestHandler {
195199

196200
Ok(req_contents)
197201
}
198-
199-
fn metrics_identifier(&self) -> &str {
200-
"/v3/tenures/:block_id"
201-
}
202202
}
203203

204204
impl RPCRequestHandler for RPCNakamotoTenureRequestHandler {

stackslib/src/net/api/gettenureinfo.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ impl HttpRequest for RPCNakamotoTenureInfoRequestHandler {
8181
Regex::new(r#"^/v3/tenures/info"#).unwrap()
8282
}
8383

84+
fn metrics_identifier(&self) -> &str {
85+
"/v3/tenures/info"
86+
}
87+
8488
/// Try to decode this request.
8589
/// There's nothing to load here, so just make sure the request is well-formed.
8690
fn try_parse_request(
@@ -97,10 +101,6 @@ impl HttpRequest for RPCNakamotoTenureInfoRequestHandler {
97101
}
98102
Ok(HttpRequestContents::new().query_string(query))
99103
}
100-
101-
fn metrics_identifier(&self) -> &str {
102-
"/v3/tenures/info"
103-
}
104104
}
105105

106106
impl RPCRequestHandler for RPCNakamotoTenureInfoRequestHandler {

stackslib/src/net/api/postblock_proposal.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@ impl HttpRequest for RPCBlockProposalRequestHandler {
376376
Regex::new(r#"^/v2/block_proposal$"#).unwrap()
377377
}
378378

379+
fn metrics_identifier(&self) -> &str {
380+
"/v2/block_proposal"
381+
}
382+
379383
/// Try to decode this request.
380384
/// There's nothing to load here, so just make sure the request is well-formed.
381385
fn try_parse_request(
@@ -424,10 +428,6 @@ impl HttpRequest for RPCBlockProposalRequestHandler {
424428
self.block_proposal = Some(block_proposal);
425429
Ok(HttpRequestContents::new().query_string(query))
426430
}
427-
428-
fn metrics_identifier(&self) -> &str {
429-
"/v2/block_proposal"
430-
}
431431
}
432432

433433
struct ProposalThreadInfo {

0 commit comments

Comments
 (0)