mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-10-20 18:56:21 +00:00
Saturating sub timestamp from now to avoid possible undeflowr (#420)
This commit is contained in:
1 parent
18a3d7a42f
commit
38c5dff0b7
1 file changed
+2
-2
@@ -259,7 +259,7 @@ impl Chain {
|
|||||||
self.best.hash,
|
self.best.hash,
|
||||||
);
|
);
|
||||||
if let Some(timestamp) = self.timestamp {
|
if let Some(timestamp) = self.timestamp {
|
||||||
self.block_times.push(now - timestamp);
|
self.block_times.push(now.saturating_sub(timestamp));
|
||||||
self.average_block_time = Some(self.block_times.average());
|
self.average_block_time = Some(self.block_times.average());
|
||||||
}
|
}
|
||||||
self.timestamp = Some(now);
|
self.timestamp = Some(now);
|
||||||
@@ -271,7 +271,7 @@ impl Chain {
|
|||||||
propagation_time = Some(0);
|
propagation_time = Some(0);
|
||||||
} else if block.height == self.best.height {
|
} else if block.height == self.best.height {
|
||||||
if let Some(timestamp) = self.timestamp {
|
if let Some(timestamp) = self.timestamp {
|
||||||
propagation_time = Some(now - timestamp);
|
propagation_time = Some(now.saturating_sub(timestamp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user