Skip to content

Commit 648c9a9

Browse files
committed
reverted getblock_v3 patch
1 parent bc0fc2e commit 648c9a9

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

stackslib/src/net/api/getblock_v3.rs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ pub struct RPCNakamotoBlockRequestHandler {
4646
pub block_id: Option<StacksBlockId>,
4747
}
4848

49+
impl RPCNakamotoBlockRequestHandler {
50+
pub fn new() -> Self {
51+
Self { block_id: None }
52+
}
53+
}
54+
4955
pub struct NakamotoBlockStream {
5056
/// index block hash of the block to download
5157
pub index_block_hash: StacksBlockId,
@@ -63,27 +69,6 @@ pub struct NakamotoBlockStream {
6369
pub rowid: i64,
6470
}
6571

66-
impl RPCNakamotoBlockRequestHandler {
67-
pub fn new() -> Self {
68-
Self { block_id: None }
69-
}
70-
71-
pub fn get_stream_by_node(
72-
block_id: &StacksBlockId,
73-
node: &mut StacksNodeState,
74-
) -> Result<NakamotoBlockStream, ChainError> {
75-
node.with_node_state(|_network, _sortdb, chainstate, _mempool, _rpc_args| {
76-
let Some((tenure_id, parent_block_id)) = chainstate
77-
.nakamoto_blocks_db()
78-
.get_tenure_and_parent_block_id(&block_id)?
79-
else {
80-
return Err(ChainError::NoSuchBlockError);
81-
};
82-
NakamotoBlockStream::new(chainstate, block_id.clone(), tenure_id, parent_block_id)
83-
})
84-
}
85-
}
86-
8772
impl NakamotoBlockStream {
8873
pub fn new(
8974
chainstate: &StacksChainState,
@@ -194,8 +179,19 @@ impl RPCRequestHandler for RPCNakamotoBlockRequestHandler {
194179
.take()
195180
.ok_or(NetError::SendError("Missing `block_id`".into()))?;
196181

182+
let stream_res =
183+
node.with_node_state(|_network, _sortdb, chainstate, _mempool, _rpc_args| {
184+
let Some((tenure_id, parent_block_id)) = chainstate
185+
.nakamoto_blocks_db()
186+
.get_tenure_and_parent_block_id(&block_id)?
187+
else {
188+
return Err(ChainError::NoSuchBlockError);
189+
};
190+
NakamotoBlockStream::new(chainstate, block_id.clone(), tenure_id, parent_block_id)
191+
});
192+
197193
// start loading up the block
198-
let stream = match Self::get_stream_by_node(&block_id, node) {
194+
let stream = match stream_res {
199195
Ok(stream) => stream,
200196
Err(ChainError::NoSuchBlockError) => {
201197
return StacksHttpResponse::new_error(

0 commit comments

Comments
 (0)