Replace best_* with finalized_*

We test their equivalency yet still better to use finalized_* in 
general.
This commit is contained in:
Luke Parker
2022-10-30 11:13:47 -04:00
parent c0056643c8
commit 503adfee2f
3 changed files with 6 additions and 6 deletions

View File

@@ -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()

View File

@@ -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(())

View File

@@ -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);