Skip to content

Commit

Permalink
refactor: add optional id_bhh to get_burn_block_time
Browse files Browse the repository at this point in the history
  • Loading branch information
obycode committed Jun 13, 2024
1 parent e496acd commit 5b1191c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions clarity/src/vm/database/clarity_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -907,8 +907,13 @@ impl<'a> ClarityDatabase<'a> {
.ok_or_else(|| InterpreterError::Expect("Failed to get block data.".into()).into())
}

pub fn get_burn_block_time(&mut self, block_height: u32) -> Result<u64> {
let id_bhh = self.get_index_block_header_hash(block_height)?;
pub fn get_burn_block_time(
&mut self,
block_height: u32,
id_bhh_opt: Option<StacksBlockId>,
) -> Result<u64> {
let id_bhh =
id_bhh_opt.unwrap_or_else(|| self.get_index_block_header_hash(block_height)?);
self.headers_db
.get_burn_block_time_for_block(&id_bhh)
.ok_or_else(|| InterpreterError::Expect("Failed to get block data.".into()).into())
Expand All @@ -925,7 +930,7 @@ impl<'a> ClarityDatabase<'a> {
)
})?;
if !epoch.epoch_id.has_block_timestamps() {
return self.get_burn_block_time(block_height);
return self.get_burn_block_time(block_height, Some(id_bhh));
}

self.headers_db
Expand Down
4 changes: 2 additions & 2 deletions clarity/src/vm/functions/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ pub fn special_get_block_info(
let block_time = env
.global_context
.database
.get_burn_block_time(height_value)?;
.get_burn_block_time(height_value, None)?;
Value::UInt(u128::from(block_time))
}
BlockInfoProperty::VrfSeed => {
Expand Down Expand Up @@ -1078,7 +1078,7 @@ pub fn special_get_tenure_info(
let block_time = env
.global_context
.database
.get_burn_block_time(height_value)?;
.get_burn_block_time(height_value, None)?;
Value::UInt(u128::from(block_time))
}
TenureInfoProperty::VrfSeed => {
Expand Down

0 comments on commit 5b1191c

Please sign in to comment.