mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-11 05:29:25 +00:00
Replace best_* with finalized_*
We test their equivalency yet still better to use finalized_* in general.
This commit is contained in:
@@ -72,10 +72,10 @@ impl<T: TendermintValidator> TendermintAuthority<T> {
|
|||||||
let info = self.import.client.info();
|
let info = self.import.client.info();
|
||||||
|
|
||||||
(
|
(
|
||||||
info.best_hash,
|
info.finalized_hash,
|
||||||
(
|
(
|
||||||
// Header::Number: TryInto<u64> doesn't implement Debug and can't be unwrapped
|
// Header::Number: TryInto<u64> doesn't implement Debug and can't be unwrapped
|
||||||
match info.best_number.try_into() {
|
match info.finalized_number.try_into() {
|
||||||
Ok(best) => BlockNumber(best),
|
Ok(best) => BlockNumber(best),
|
||||||
Err(_) => panic!("BlockNumber exceeded u64"),
|
Err(_) => panic!("BlockNumber exceeded u64"),
|
||||||
},
|
},
|
||||||
@@ -85,7 +85,7 @@ impl<T: TendermintValidator> TendermintAuthority<T> {
|
|||||||
&mut self
|
&mut self
|
||||||
.import
|
.import
|
||||||
.client
|
.client
|
||||||
.justifications(&BlockId::Hash(info.best_hash))
|
.justifications(&BlockId::Hash(info.finalized_hash))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.map(|justifications| justifications.get(CONSENSUS_ID).cloned().unwrap())
|
.map(|justifications| justifications.get(CONSENSUS_ID).cloned().unwrap())
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ impl<T: TendermintValidator> TendermintImport<T> {
|
|||||||
number: <<T::Block as Block>::Header as Header>::Number,
|
number: <<T::Block as Block>::Header as Header>::Number,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let info = self.client.info();
|
let info = self.client.info();
|
||||||
if (info.best_hash != parent) || ((info.best_number + 1u16.into()) != number) {
|
if (info.finalized_hash != parent) || ((info.finalized_number + 1u16.into()) != number) {
|
||||||
Err(Error::Other("non-sequential import".into()))?;
|
Err(Error::Other("non-sequential import".into()))?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ struct TendermintValidatorsStruct {
|
|||||||
|
|
||||||
impl TendermintValidatorsStruct {
|
impl TendermintValidatorsStruct {
|
||||||
fn from_module<T: TendermintClient>(client: &Arc<T::Client>) -> TendermintValidatorsStruct {
|
fn from_module<T: TendermintClient>(client: &Arc<T::Client>) -> TendermintValidatorsStruct {
|
||||||
let last = client.info().best_hash;
|
let last = client.info().finalized_hash;
|
||||||
let api = client.runtime_api();
|
let api = client.runtime_api();
|
||||||
let session = api.current_session(&BlockId::Hash(last)).unwrap();
|
let session = api.current_session(&BlockId::Hash(last)).unwrap();
|
||||||
let validators = api.validators(&BlockId::Hash(last)).unwrap();
|
let validators = api.validators(&BlockId::Hash(last)).unwrap();
|
||||||
@@ -63,7 +63,7 @@ impl<T: TendermintClient> Refresh<T> {
|
|||||||
self
|
self
|
||||||
.client
|
.client
|
||||||
.runtime_api()
|
.runtime_api()
|
||||||
.current_session(&BlockId::Hash(self.client.info().best_hash))
|
.current_session(&BlockId::Hash(self.client.info().finalized_hash))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
{
|
{
|
||||||
*self._refresh.write().unwrap() = TendermintValidatorsStruct::from_module::<T>(&self.client);
|
*self._refresh.write().unwrap() = TendermintValidatorsStruct::from_module::<T>(&self.client);
|
||||||
|
|||||||
Reference in New Issue
Block a user