style: Migrate to stable-only rustfmt configuration
- Remove nightly-only features from .rustfmt.toml and vendor/ss58-registry/rustfmt.toml - Removed features: imports_granularity, wrap_comments, comment_width, reorder_impl_items, spaces_around_ranges, binop_separator, match_arm_blocks, trailing_semicolon, trailing_comma - Format all 898 affected files with stable rustfmt - Ensures long-term reliability without nightly toolchain dependency
This commit is contained in:
@@ -233,8 +233,8 @@ where
|
||||
let key = StorageKey(parse_hex_param(query.key)?);
|
||||
|
||||
// Validate that paginationStartKey is only used with descendant queries
|
||||
if query.pagination_start_key.is_some() &&
|
||||
!query.query_type.is_descendant_query()
|
||||
if query.pagination_start_key.is_some()
|
||||
&& !query.query_type.is_descendant_query()
|
||||
{
|
||||
return Err(ArchiveError::InvalidParam(
|
||||
"paginationStartKey is only valid for descendantsValues and descendantsHashes query types"
|
||||
|
||||
@@ -234,8 +234,9 @@ where
|
||||
};
|
||||
|
||||
let maybe_result = match operation_type {
|
||||
ArchiveStorageDiffOperationType::Added =>
|
||||
self.fetch_storage(hash, key.clone(), maybe_child_trie.clone(), fetch_type)?,
|
||||
ArchiveStorageDiffOperationType::Added => {
|
||||
self.fetch_storage(hash, key.clone(), maybe_child_trie.clone(), fetch_type)?
|
||||
},
|
||||
ArchiveStorageDiffOperationType::Deleted => self.fetch_storage(
|
||||
previous_hash,
|
||||
key.clone(),
|
||||
@@ -373,7 +374,7 @@ where
|
||||
let mut b = right.next();
|
||||
|
||||
core::iter::from_fn(move || match (a.take(), b.take()) {
|
||||
(Some(a_value), Some(b_value)) =>
|
||||
(Some(a_value), Some(b_value)) => {
|
||||
if a_value < b_value {
|
||||
b = Some(b_value);
|
||||
a = left.next();
|
||||
@@ -389,7 +390,8 @@ where
|
||||
b = right.next();
|
||||
|
||||
Some(Diff::Equal(a_value))
|
||||
},
|
||||
}
|
||||
},
|
||||
(Some(a_value), None) => {
|
||||
a = left.next();
|
||||
Some(Diff::Added(a_value))
|
||||
|
||||
@@ -276,9 +276,10 @@ where
|
||||
let result = spawn_blocking(&self.executor, async move {
|
||||
let mut block_guard = match subscriptions.lock_block(&follow_subscription, hash, 1) {
|
||||
Ok(block) => block,
|
||||
Err(SubscriptionManagementError::SubscriptionAbsent) |
|
||||
Err(SubscriptionManagementError::ExceededLimits) =>
|
||||
return ResponsePayload::success(MethodResponse::LimitReached),
|
||||
Err(SubscriptionManagementError::SubscriptionAbsent)
|
||||
| Err(SubscriptionManagementError::ExceededLimits) => {
|
||||
return ResponsePayload::success(MethodResponse::LimitReached)
|
||||
},
|
||||
Err(SubscriptionManagementError::BlockHashAbsent) => {
|
||||
// Block is not part of the subscription.
|
||||
return ResponsePayload::error(ChainHeadRpcError::InvalidBlock);
|
||||
@@ -355,8 +356,8 @@ where
|
||||
|
||||
let block_guard = match self.subscriptions.lock_block(&follow_subscription, hash, 1) {
|
||||
Ok(block) => block,
|
||||
Err(SubscriptionManagementError::SubscriptionAbsent) |
|
||||
Err(SubscriptionManagementError::ExceededLimits) => return Ok(None),
|
||||
Err(SubscriptionManagementError::SubscriptionAbsent)
|
||||
| Err(SubscriptionManagementError::ExceededLimits) => return Ok(None),
|
||||
Err(SubscriptionManagementError::BlockHashAbsent) => {
|
||||
// Block is not part of the subscription.
|
||||
return Err(ChainHeadRpcError::InvalidBlock.into());
|
||||
@@ -419,8 +420,8 @@ where
|
||||
let mut block_guard =
|
||||
match self.subscriptions.lock_block(&follow_subscription, hash, items.len()) {
|
||||
Ok(block) => block,
|
||||
Err(SubscriptionManagementError::SubscriptionAbsent) |
|
||||
Err(SubscriptionManagementError::ExceededLimits) => {
|
||||
Err(SubscriptionManagementError::SubscriptionAbsent)
|
||||
| Err(SubscriptionManagementError::ExceededLimits) => {
|
||||
return ResponsePayload::success(MethodResponse::LimitReached);
|
||||
},
|
||||
Err(SubscriptionManagementError::BlockHashAbsent) => {
|
||||
@@ -486,8 +487,8 @@ where
|
||||
|
||||
let mut block_guard = match self.subscriptions.lock_block(&follow_subscription, hash, 1) {
|
||||
Ok(block) => block,
|
||||
Err(SubscriptionManagementError::SubscriptionAbsent) |
|
||||
Err(SubscriptionManagementError::ExceededLimits) => {
|
||||
Err(SubscriptionManagementError::SubscriptionAbsent)
|
||||
| Err(SubscriptionManagementError::ExceededLimits) => {
|
||||
// Invalid invalid subscription ID.
|
||||
return ResponsePayload::success(MethodResponse::LimitReached);
|
||||
},
|
||||
@@ -556,10 +557,12 @@ where
|
||||
}
|
||||
|
||||
let result = match hash_or_hashes {
|
||||
ListOrValue::Value(hash) =>
|
||||
self.subscriptions.unpin_blocks(&follow_subscription, [hash]),
|
||||
ListOrValue::List(hashes) =>
|
||||
self.subscriptions.unpin_blocks(&follow_subscription, hashes),
|
||||
ListOrValue::Value(hash) => {
|
||||
self.subscriptions.unpin_blocks(&follow_subscription, [hash])
|
||||
},
|
||||
ListOrValue::List(hashes) => {
|
||||
self.subscriptions.unpin_blocks(&follow_subscription, hashes)
|
||||
},
|
||||
};
|
||||
|
||||
match result {
|
||||
@@ -572,8 +575,9 @@ where
|
||||
// Block is not part of the subscription.
|
||||
Err(ChainHeadRpcError::InvalidBlock)
|
||||
},
|
||||
Err(SubscriptionManagementError::DuplicateHashes) =>
|
||||
Err(ChainHeadRpcError::InvalidDuplicateHashes),
|
||||
Err(SubscriptionManagementError::DuplicateHashes) => {
|
||||
Err(ChainHeadRpcError::InvalidDuplicateHashes)
|
||||
},
|
||||
Err(_) => Err(ChainHeadRpcError::InvalidBlock),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +257,9 @@ where
|
||||
let parent = match parent {
|
||||
Some(parent) => parent,
|
||||
// Nothing to compare against, always report.
|
||||
None => return Some(RuntimeEvent::Valid(RuntimeVersionEvent { spec: block_rt.into() })),
|
||||
None => {
|
||||
return Some(RuntimeEvent::Valid(RuntimeVersionEvent { spec: block_rt.into() }))
|
||||
},
|
||||
};
|
||||
|
||||
let parent_rt = match self.client.runtime_version_at(parent) {
|
||||
@@ -522,7 +524,9 @@ where
|
||||
let parent_block_hash = *notification.header.parent_hash();
|
||||
if !self.announced_blocks.was_announced(&parent_block_hash) {
|
||||
// The parent block was not reported, we have a gap.
|
||||
return Err(SubscriptionManagementError::Custom("Parent block was not reported".into()));
|
||||
return Err(SubscriptionManagementError::Custom(
|
||||
"Parent block was not reported".into(),
|
||||
));
|
||||
}
|
||||
|
||||
self.announced_blocks.insert(block_hash, false);
|
||||
@@ -714,10 +718,12 @@ where
|
||||
// create a channel to propagate error messages
|
||||
let mut handle_events = |event| match event {
|
||||
NotificationType::InitialEvents(events) => Ok(events),
|
||||
NotificationType::NewBlock(notification) =>
|
||||
self.handle_import_blocks(notification, &startup_point),
|
||||
NotificationType::Finalized(notification) =>
|
||||
self.handle_finalized_blocks(notification, &startup_point),
|
||||
NotificationType::NewBlock(notification) => {
|
||||
self.handle_import_blocks(notification, &startup_point)
|
||||
},
|
||||
NotificationType::Finalized(notification) => {
|
||||
self.handle_finalized_blocks(notification, &startup_point)
|
||||
},
|
||||
NotificationType::MethodResponse(notification) => Ok(vec![notification]),
|
||||
};
|
||||
|
||||
|
||||
@@ -75,20 +75,27 @@ impl From<Error> for ErrorObject<'static> {
|
||||
let msg = e.to_string();
|
||||
|
||||
match e {
|
||||
Error::ReachedLimits =>
|
||||
ErrorObject::owned(rpc_spec_v2::REACHED_LIMITS, msg, None::<()>),
|
||||
Error::InvalidBlock =>
|
||||
ErrorObject::owned(rpc_spec_v2::INVALID_BLOCK_ERROR, msg, None::<()>),
|
||||
Error::InvalidRuntimeCall(_) =>
|
||||
ErrorObject::owned(rpc_spec_v2::INVALID_RUNTIME_CALL, msg, None::<()>),
|
||||
Error::InvalidContinue =>
|
||||
ErrorObject::owned(rpc_spec_v2::INVALID_CONTINUE, msg, None::<()>),
|
||||
Error::InvalidDuplicateHashes =>
|
||||
ErrorObject::owned(rpc_spec_v2::INVALID_DUPLICATE_HASHES, msg, None::<()>),
|
||||
Error::InvalidParam(_) =>
|
||||
ErrorObject::owned(json_rpc_spec::INVALID_PARAM_ERROR, msg, None::<()>),
|
||||
Error::InternalError(_) =>
|
||||
ErrorObject::owned(json_rpc_spec::INTERNAL_ERROR, msg, None::<()>),
|
||||
Error::ReachedLimits => {
|
||||
ErrorObject::owned(rpc_spec_v2::REACHED_LIMITS, msg, None::<()>)
|
||||
},
|
||||
Error::InvalidBlock => {
|
||||
ErrorObject::owned(rpc_spec_v2::INVALID_BLOCK_ERROR, msg, None::<()>)
|
||||
},
|
||||
Error::InvalidRuntimeCall(_) => {
|
||||
ErrorObject::owned(rpc_spec_v2::INVALID_RUNTIME_CALL, msg, None::<()>)
|
||||
},
|
||||
Error::InvalidContinue => {
|
||||
ErrorObject::owned(rpc_spec_v2::INVALID_CONTINUE, msg, None::<()>)
|
||||
},
|
||||
Error::InvalidDuplicateHashes => {
|
||||
ErrorObject::owned(rpc_spec_v2::INVALID_DUPLICATE_HASHES, msg, None::<()>)
|
||||
},
|
||||
Error::InvalidParam(_) => {
|
||||
ErrorObject::owned(json_rpc_spec::INVALID_PARAM_ERROR, msg, None::<()>)
|
||||
},
|
||||
Error::InternalError(_) => {
|
||||
ErrorObject::owned(json_rpc_spec::INTERNAL_ERROR, msg, None::<()>)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3335,16 +3335,18 @@ async fn storage_closest_merkle_value() {
|
||||
|
||||
loop {
|
||||
match get_next_event::<FollowEvent<String>>(&mut sub).await {
|
||||
FollowEvent::OperationStorageItems(res) if res.operation_id == operation_id =>
|
||||
FollowEvent::OperationStorageItems(res) if res.operation_id == operation_id => {
|
||||
for res in res.items {
|
||||
let value = match res.result {
|
||||
StorageResultType::ClosestDescendantMerkleValue(value) => value,
|
||||
_ => panic!("Unexpected StorageResultType"),
|
||||
};
|
||||
merkle_values.insert(res.key, value);
|
||||
},
|
||||
FollowEvent::OperationStorageDone(done) if done.operation_id == operation_id =>
|
||||
break,
|
||||
}
|
||||
},
|
||||
FollowEvent::OperationStorageDone(done) if done.operation_id == operation_id => {
|
||||
break
|
||||
},
|
||||
_ => panic!("Unexpected event"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,10 +42,11 @@ impl<Hash> From<Error> for TransactionEvent<Hash> {
|
||||
Error::Verification(e) => TransactionEvent::Invalid(TransactionError {
|
||||
error: format!("Verification error: {}", e),
|
||||
}),
|
||||
Error::Pool(PoolError::InvalidTransaction(InvalidTransaction::Custom(e))) =>
|
||||
Error::Pool(PoolError::InvalidTransaction(InvalidTransaction::Custom(e))) => {
|
||||
TransactionEvent::Invalid(TransactionError {
|
||||
error: format!("Invalid transaction with custom error: {}", e),
|
||||
}),
|
||||
})
|
||||
},
|
||||
Error::Pool(PoolError::InvalidTransaction(e)) => {
|
||||
let msg: &str = e.into();
|
||||
TransactionEvent::Invalid(TransactionError {
|
||||
@@ -58,28 +59,32 @@ impl<Hash> From<Error> for TransactionEvent<Hash> {
|
||||
error: format!("Unknown transaction validity: {}", msg),
|
||||
})
|
||||
},
|
||||
Error::Pool(PoolError::TemporarilyBanned) =>
|
||||
Error::Pool(PoolError::TemporarilyBanned) => {
|
||||
TransactionEvent::Invalid(TransactionError {
|
||||
error: "Transaction is temporarily banned".into(),
|
||||
}),
|
||||
Error::Pool(PoolError::AlreadyImported(_)) =>
|
||||
})
|
||||
},
|
||||
Error::Pool(PoolError::AlreadyImported(_)) => {
|
||||
TransactionEvent::Invalid(TransactionError {
|
||||
error: "Transaction is already imported".into(),
|
||||
}),
|
||||
Error::Pool(PoolError::TooLowPriority { old, new }) =>
|
||||
})
|
||||
},
|
||||
Error::Pool(PoolError::TooLowPriority { old, new }) => {
|
||||
TransactionEvent::Invalid(TransactionError {
|
||||
error: format!(
|
||||
"The priority of the transaction is too low (pool {} > current {})",
|
||||
old, new
|
||||
),
|
||||
}),
|
||||
})
|
||||
},
|
||||
Error::Pool(PoolError::CycleDetected) => TransactionEvent::Invalid(TransactionError {
|
||||
error: "The transaction contains a cyclic dependency".into(),
|
||||
}),
|
||||
Error::Pool(PoolError::ImmediatelyDropped) =>
|
||||
Error::Pool(PoolError::ImmediatelyDropped) => {
|
||||
TransactionEvent::Invalid(TransactionError {
|
||||
error: "The transaction could not enter the pool because of the limit".into(),
|
||||
}),
|
||||
})
|
||||
},
|
||||
Error::Pool(PoolError::Unactionable) => TransactionEvent::Invalid(TransactionError {
|
||||
error: "Transaction cannot be propagated and the local node does not author blocks"
|
||||
.into(),
|
||||
@@ -88,14 +93,16 @@ impl<Hash> From<Error> for TransactionEvent<Hash> {
|
||||
error: "Transaction does not provide any tags, so the pool cannot identify it"
|
||||
.into(),
|
||||
}),
|
||||
Error::Pool(PoolError::InvalidBlockId(_)) =>
|
||||
Error::Pool(PoolError::InvalidBlockId(_)) => {
|
||||
TransactionEvent::Invalid(TransactionError {
|
||||
error: "The provided block ID is not valid".into(),
|
||||
}),
|
||||
Error::Pool(PoolError::RejectedFutureTransaction) =>
|
||||
})
|
||||
},
|
||||
Error::Pool(PoolError::RejectedFutureTransaction) => {
|
||||
TransactionEvent::Invalid(TransactionError {
|
||||
error: "The pool is not accepting future transactions".into(),
|
||||
}),
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,8 +127,9 @@ impl From<ErrorBroadcast> for ErrorObject<'static> {
|
||||
let msg = e.to_string();
|
||||
|
||||
match e {
|
||||
ErrorBroadcast::InvalidOperationID =>
|
||||
ErrorObject::owned(json_rpc_spec::INVALID_PARAM_ERROR, msg, None::<()>),
|
||||
ErrorBroadcast::InvalidOperationID => {
|
||||
ErrorObject::owned(json_rpc_spec::INVALID_PARAM_ERROR, msg, None::<()>)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,10 +100,10 @@ impl<Hash> TransactionEvent<Hash> {
|
||||
pub fn is_final(&self) -> bool {
|
||||
matches!(
|
||||
&self,
|
||||
TransactionEvent::Finalized(_) |
|
||||
TransactionEvent::Error(_) |
|
||||
TransactionEvent::Invalid(_) |
|
||||
TransactionEvent::Dropped(_)
|
||||
TransactionEvent::Finalized(_)
|
||||
| TransactionEvent::Error(_)
|
||||
| TransactionEvent::Invalid(_)
|
||||
| TransactionEvent::Dropped(_)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -171,18 +171,24 @@ enum TransactionEventIR<Hash> {
|
||||
impl<Hash> From<TransactionEvent<Hash>> for TransactionEventIR<Hash> {
|
||||
fn from(value: TransactionEvent<Hash>) -> Self {
|
||||
match value {
|
||||
TransactionEvent::Validated =>
|
||||
TransactionEventIR::NonBlock(TransactionEventNonBlockIR::Validated),
|
||||
TransactionEvent::BestChainBlockIncluded(event) =>
|
||||
TransactionEventIR::Block(TransactionEventBlockIR::BestChainBlockIncluded(event)),
|
||||
TransactionEvent::Finalized(event) =>
|
||||
TransactionEventIR::Block(TransactionEventBlockIR::Finalized(event)),
|
||||
TransactionEvent::Error(event) =>
|
||||
TransactionEventIR::NonBlock(TransactionEventNonBlockIR::Error(event)),
|
||||
TransactionEvent::Invalid(event) =>
|
||||
TransactionEventIR::NonBlock(TransactionEventNonBlockIR::Invalid(event)),
|
||||
TransactionEvent::Dropped(event) =>
|
||||
TransactionEventIR::NonBlock(TransactionEventNonBlockIR::Dropped(event)),
|
||||
TransactionEvent::Validated => {
|
||||
TransactionEventIR::NonBlock(TransactionEventNonBlockIR::Validated)
|
||||
},
|
||||
TransactionEvent::BestChainBlockIncluded(event) => {
|
||||
TransactionEventIR::Block(TransactionEventBlockIR::BestChainBlockIncluded(event))
|
||||
},
|
||||
TransactionEvent::Finalized(event) => {
|
||||
TransactionEventIR::Block(TransactionEventBlockIR::Finalized(event))
|
||||
},
|
||||
TransactionEvent::Error(event) => {
|
||||
TransactionEventIR::NonBlock(TransactionEventNonBlockIR::Error(event))
|
||||
},
|
||||
TransactionEvent::Invalid(event) => {
|
||||
TransactionEventIR::NonBlock(TransactionEventNonBlockIR::Invalid(event))
|
||||
},
|
||||
TransactionEvent::Dropped(event) => {
|
||||
TransactionEventIR::NonBlock(TransactionEventNonBlockIR::Dropped(event))
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,8 +204,9 @@ impl<Hash> From<TransactionEventIR<Hash>> for TransactionEvent<Hash> {
|
||||
},
|
||||
TransactionEventIR::Block(block) => match block {
|
||||
TransactionEventBlockIR::Finalized(event) => TransactionEvent::Finalized(event),
|
||||
TransactionEventBlockIR::BestChainBlockIncluded(event) =>
|
||||
TransactionEvent::BestChainBlockIncluded(event),
|
||||
TransactionEventBlockIR::BestChainBlockIncluded(event) => {
|
||||
TransactionEvent::BestChainBlockIncluded(event)
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,17 +165,21 @@ fn handle_event<Hash: Clone, BlockHash: Clone>(
|
||||
event: TransactionStatus<Hash, BlockHash>,
|
||||
) -> Option<TransactionEvent<BlockHash>> {
|
||||
match event {
|
||||
TransactionStatus::Ready | TransactionStatus::Future =>
|
||||
Some(TransactionEvent::<BlockHash>::Validated),
|
||||
TransactionStatus::InBlock((hash, index)) =>
|
||||
Some(TransactionEvent::BestChainBlockIncluded(Some(TransactionBlock { hash, index }))),
|
||||
TransactionStatus::Ready | TransactionStatus::Future => {
|
||||
Some(TransactionEvent::<BlockHash>::Validated)
|
||||
},
|
||||
TransactionStatus::InBlock((hash, index)) => {
|
||||
Some(TransactionEvent::BestChainBlockIncluded(Some(TransactionBlock { hash, index })))
|
||||
},
|
||||
TransactionStatus::Retracted(_) => Some(TransactionEvent::BestChainBlockIncluded(None)),
|
||||
TransactionStatus::FinalityTimeout(_) =>
|
||||
TransactionStatus::FinalityTimeout(_) => {
|
||||
Some(TransactionEvent::Dropped(TransactionDropped {
|
||||
error: "Maximum number of finality watchers has been reached".into(),
|
||||
})),
|
||||
TransactionStatus::Finalized((hash, index)) =>
|
||||
Some(TransactionEvent::Finalized(TransactionBlock { hash, index })),
|
||||
}))
|
||||
},
|
||||
TransactionStatus::Finalized((hash, index)) => {
|
||||
Some(TransactionEvent::Finalized(TransactionBlock { hash, index }))
|
||||
},
|
||||
TransactionStatus::Usurped(_) => Some(TransactionEvent::Invalid(TransactionError {
|
||||
error: "Extrinsic was rendered invalid by another extrinsic".into(),
|
||||
})),
|
||||
|
||||
Reference in New Issue
Block a user