Skip to content

Commit 6e4db07

Browse files
committed
chore: reuse cached state also in postmempoolquery.rs
1 parent 07a06c0 commit 6e4db07

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

stackslib/src/net/api/getinfo.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,12 @@ impl RPCRequestHandler for RPCPeerInfoRequestHandler {
224224

225225
let rpc_peer_info: Result<RPCPeerInfoData, StacksHttpResponse> =
226226
node.with_node_state(|network, sortdb, chainstate, _mempool, rpc_args| {
227-
let header = self
228-
.get_stacks_chain_tip(&preamble, sortdb, chainstate)
229-
.map_err(|e| {
230-
StacksHttpResponse::new_error(
231-
&preamble,
232-
&HttpServerError::new(format!("Failed to load chain tip: {:?}", &e)),
233-
)
234-
})?;
235-
236227
let coinbase_height = NakamotoChainState::get_coinbase_height(
237228
&mut chainstate.index_conn(),
238-
&StacksBlockId::new(&network.stacks_tip.consensus_hash, &network.stacks_tip.block_hash),
229+
&StacksBlockId::new(
230+
&network.stacks_tip.consensus_hash,
231+
&network.stacks_tip.block_hash,
232+
),
239233
)
240234
.map_err(|e| {
241235
StacksHttpResponse::new_error(

stackslib/src/net/api/postmempoolquery.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ impl StacksMemPoolStream {
116116

117117
Self {
118118
tx_query,
119-
last_randomized_txid: last_randomized_txid,
119+
last_randomized_txid,
120120
num_txs: 0,
121-
max_txs: max_txs,
121+
max_txs,
122122
coinbase_height,
123123
corked: false,
124124
finished: false,
@@ -276,10 +276,13 @@ impl RPCRequestHandler for RPCMempoolQueryRequestHandler {
276276
let page_id = self.page_id.take();
277277

278278
let stream_res = node.with_node_state(|network, sortdb, chainstate, mempool, _rpc_args| {
279-
let header = self.get_stacks_chain_tip(&preamble, sortdb, chainstate)
280-
.map_err(|e| StacksHttpResponse::new_error(&preamble, &HttpServerError::new(format!("Failed to load chain tip: {:?}", &e))))?;
281-
282-
let coinbase_height = NakamotoChainState::get_coinbase_height(&mut chainstate.index_conn(), &header.index_block_hash())
279+
let coinbase_height = NakamotoChainState::get_coinbase_height(
280+
&mut chainstate.index_conn(),
281+
&StacksBlockId::new(
282+
&network.stacks_tip.consensus_hash,
283+
&network.stacks_tip.block_hash
284+
),
285+
)
283286
.map_err(|e| StacksHttpResponse::new_error(&preamble, &HttpServerError::new(format!("Failed to load coinbase height: {:?}", &e))))?
284287
.unwrap_or(0);
285288

0 commit comments

Comments
 (0)