Skip to content

Commit 439abdb

Browse files
committed
fix: accomodate shadow blocks which have no sortition but do have a shadow tenure entry
1 parent ca17ede commit 439abdb

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

stackslib/src/net/api/get_tenures_fork_info.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,21 +231,29 @@ impl RPCRequestHandler for GetTenuresForkInfo {
231231
chainstate,
232232
&network.stacks_tip.block_id(),
233233
)?);
234-
let handle = sortdb.index_handle(&cursor.sortition_id);
235234
let mut depth = 0;
236235
while depth < DEPTH_LIMIT && cursor.consensus_hash != recurse_end {
237236
depth += 1;
238237
if height_bound >= cursor.block_height {
239238
return Err(ChainError::NotInSameFork);
240239
}
241-
cursor = handle
242-
.get_last_snapshot_with_sortition(cursor.block_height.saturating_sub(1))?;
243-
results.push(TenureForkingInfo::from_snapshot(
244-
&cursor,
245-
sortdb,
246-
chainstate,
247-
&network.stacks_tip.block_id(),
248-
)?);
240+
241+
if cursor.sortition
242+
|| chainstate
243+
.nakamoto_blocks_db()
244+
.is_shadow_tenure(&cursor.consensus_hash)?
245+
{
246+
results.push(TenureForkingInfo::from_snapshot(
247+
&cursor,
248+
sortdb,
249+
chainstate,
250+
&network.stacks_tip.block_id(),
251+
)?);
252+
}
253+
254+
cursor =
255+
SortitionDB::get_block_snapshot(sortdb.conn(), &cursor.parent_sortition_id)?
256+
.ok_or_else(|| ChainError::NoSuchBlockError)?;
249257
}
250258

251259
Ok(results)

0 commit comments

Comments
 (0)