mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-10 05:09:22 +00:00
Move TendermintMachine from start_num, time to last_num, time
Provides an explicitly clear API clearer to program around. Also adds additional time code to handle an edge case.
This commit is contained in:
@@ -61,11 +61,11 @@ impl<T: TendermintValidator> TendermintAuthority<T> {
|
||||
let info = self.0.client.info();
|
||||
|
||||
// Header::Number: TryInto<u64> doesn't implement Debug and can't be unwrapped
|
||||
let start_number = match TryInto::<u64>::try_into(info.best_number) {
|
||||
Ok(best) => BlockNumber(best + 1),
|
||||
let last_number = match info.best_number.try_into() {
|
||||
Ok(best) => BlockNumber(best),
|
||||
Err(_) => panic!("BlockNumber exceeded u64"),
|
||||
};
|
||||
let start_time = Commit::<TendermintValidators<T>>::decode(
|
||||
let last_time = Commit::<TendermintValidators<T>>::decode(
|
||||
&mut self
|
||||
.0
|
||||
.client
|
||||
@@ -76,7 +76,7 @@ impl<T: TendermintValidator> TendermintAuthority<T> {
|
||||
.as_ref(),
|
||||
)
|
||||
.map(|commit| commit.end_time)
|
||||
// TODO: Genesis start time
|
||||
// TODO: Genesis start time + BLOCK_TIME
|
||||
.unwrap_or_else(|_| SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs());
|
||||
|
||||
let proposal = self
|
||||
@@ -88,7 +88,7 @@ impl<T: TendermintValidator> TendermintAuthority<T> {
|
||||
self.0.clone(),
|
||||
// TODO
|
||||
0, // ValidatorId
|
||||
(start_number, start_time),
|
||||
(last_number, last_time),
|
||||
proposal,
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user