Update sc_tendermint per previous commit

This commit is contained in:
Luke Parker
2022-11-02 21:37:06 -04:00
parent f3e177109d
commit 2b503b6f42
5 changed files with 99 additions and 88 deletions

View File

@@ -1,11 +1,9 @@
use std::{boxed::Box, sync::Arc, error::Error};
use sp_keystore::SyncCryptoStore;
use sp_runtime::traits::{Block as BlockTrait};
use sp_inherents::CreateInherentDataProviders;
use sp_consensus::DisableProofRecording;
use sp_api::{BlockId, ProvideRuntimeApi};
use sp_tendermint::TendermintApi;
use sp_api::ProvideRuntimeApi;
use sc_executor::{NativeVersion, NativeExecutionDispatch, NativeElseWasmExecutor};
use sc_transaction_pool::FullPool;
@@ -231,44 +229,23 @@ pub async fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceE
})?;
if is_authority {
let keys = keystore_container.sync_keystore();
let key = SyncCryptoStore::sr25519_public_keys(&*keys, sc_tendermint::KEY_TYPE_ID)
.get(0)
.cloned()
.unwrap_or_else(|| {
SyncCryptoStore::sr25519_generate_new(&*keys, sc_tendermint::KEY_TYPE_ID, None).unwrap()
});
let mut spawned = false;
let mut validators =
client.runtime_api().validators(&BlockId::Hash(client.chain_info().finalized_hash)).unwrap();
for (i, validator) in validators.drain(..).enumerate() {
if validator == key {
task_manager.spawn_essential_handle().spawn(
"tendermint",
None,
TendermintAuthority::new(authority).authority(
(u16::try_from(i).unwrap(), keystore_container.keystore()),
Cidp,
sc_basic_authorship::ProposerFactory::new(
task_manager.spawn_handle(),
client,
transaction_pool,
registry.as_ref(),
telemetry.map(|telemtry| telemtry.handle()),
),
network,
None,
),
);
spawned = true;
break;
}
}
if !spawned {
log::warn!("authority role yet not a validator");
}
task_manager.spawn_essential_handle().spawn(
"tendermint",
None,
TendermintAuthority::new(authority).authority(
keystore_container.keystore(),
Cidp,
sc_basic_authorship::ProposerFactory::new(
task_manager.spawn_handle(),
client,
transaction_pool,
registry.as_ref(),
telemetry.map(|telemtry| telemtry.handle()),
),
network,
None,
),
);
}
network_starter.start_network();