Skip to content

Commit 87c409e

Browse files
author
Ludo Galabru
committed
fix: moving stacks tip
1 parent f39259c commit 87c409e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

components/chainhook-cli/src/scan/stacks.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ pub async fn scan_stacks_chainstate_via_rocksdb_using_predicate(
128128
}
129129
};
130130

131-
let mut end_block = match predicate_spec.end_block {
132-
Some(end_block) => end_block,
131+
let (mut end_block, follow_tip) = match predicate_spec.end_block {
132+
Some(end_block) => (end_block, false),
133133
None => match get_last_unconfirmed_block_height_inserted(stacks_db_conn, ctx) {
134-
Some(end_block) => end_block,
134+
Some(end_block) => (end_block, true),
135135
None => match get_last_block_height_inserted(stacks_db_conn, ctx) {
136-
Some(end_block) => end_block,
136+
Some(end_block) => (end_block, true),
137137
None => {
138138
return Err(
139139
"Chainhook specification must include fields 'end_block' when using the scan command"
@@ -226,7 +226,7 @@ pub async fn scan_stacks_chainstate_via_rocksdb_using_predicate(
226226

227227
cursor += 1;
228228
// Update end_block, in case a new block was discovered during the scan
229-
if cursor == end_block {
229+
if cursor == end_block && follow_tip {
230230
end_block = match predicate_spec.end_block {
231231
Some(end_block) => end_block,
232232
None => match get_last_unconfirmed_block_height_inserted(stacks_db_conn, ctx) {

0 commit comments

Comments
 (0)