Skip to content

Commit

Permalink
fix: from parent block to calculate median_block_timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
jjyr committed Apr 11, 2019
1 parent 9abfd68 commit 44f2a22
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions verification/src/transaction_verifier.rs
Expand Up @@ -320,7 +320,9 @@ where
}

if let Some(block_timestamp) = valid_since.block_timestamp() {
let tip_timestamp = self.block_median_time(self.tip_number).unwrap_or_else(|| 0);
let tip_timestamp = self
.block_median_time(self.tip_number.saturating_sub(1))
.unwrap_or_else(|| 0);
if tip_timestamp < block_timestamp {
return Err(TransactionError::Immature);
}
Expand All @@ -346,9 +348,11 @@ where
}

if let Some(block_timestamp) = valid_since.block_timestamp() {
let tip_timestamp = self.block_median_time(self.tip_number).unwrap_or_else(|| 0);
let tip_timestamp = self
.block_median_time(self.tip_number.saturating_sub(1))
.unwrap_or_else(|| 0);
let median_timestamp = self
.block_median_time(cell_block_number)
.block_median_time(cell_block_number.saturating_sub(1))
.unwrap_or_else(|| 0);
if tip_timestamp < median_timestamp + block_timestamp {
return Err(TransactionError::Immature);
Expand Down

0 comments on commit 44f2a22

Please sign in to comment.