Skip to content

Commit

Permalink
Address review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvc94ch committed Jun 24, 2020
1 parent 456578a commit aad43f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
4 changes: 1 addition & 3 deletions client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ fn start_subxt_client<C: ChainSpec + 'static, S: AbstractService>(
impl_version: config.impl_version,
chain_spec: Box::new(config.chain_spec),
role: config.role.into(),
task_executor: /*TaskExecutor::from(*/std::sync::Arc::new(move |fut, ty| {
task_executor: std::sync::Arc::new(move |fut, ty| {
match ty {
TaskType::Async => task::spawn(fut),
TaskType::Blocking => task::spawn_blocking(|| task::block_on(fut)),
Expand All @@ -219,7 +219,6 @@ fn start_subxt_client<C: ChainSpec + 'static, S: AbstractService>(
max_runtime_instances: 8,
announce_block: true,
dev_key_seed: config.role.into(),
//base_path: None,

telemetry_endpoints: Default::default(),
telemetry_external_transport: Default::default(),
Expand All @@ -232,7 +231,6 @@ fn start_subxt_client<C: ChainSpec + 'static, S: AbstractService>(
pruning: Default::default(),
rpc_cors: Default::default(),
rpc_http: Default::default(),
//rpc_ipc: Default::default(),
rpc_ws: Default::default(),
rpc_ws_max_connections: Default::default(),
rpc_methods: Default::default(),
Expand Down
20 changes: 8 additions & 12 deletions src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,14 @@ impl<T: Runtime> Rpc<T> {
block_hash,
signed_block.block.extrinsics.len()
);
let ext_index = find_extrinsic::<T>(&signed_block, &ext_hash)
let ext_index = signed_block
.block
.extrinsics
.iter()
.position(|ext| {
let hash = T::Hashing::hash_of(ext);
hash == ext_hash
})
.ok_or_else(|| {
Error::Other(format!(
"Failed to find Extrinsic with hash {:?}",
Expand Down Expand Up @@ -433,14 +440,3 @@ impl<T: System> ExtrinsicSuccess<T> {
}
}
}

/// Returns the index of an extrinsic in a block.
pub fn find_extrinsic<T: Runtime>(
signed_block: &ChainBlock<T>,
extrinsic: &T::Hash,
) -> Option<usize> {
signed_block.block.extrinsics.iter().position(|ext| {
let hash = T::Hashing::hash_of(ext);
hash == *extrinsic
})
}

0 comments on commit aad43f5

Please sign in to comment.