mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 20:57:59 +00:00
Allow runtime to return transaction validation error codes (#1534)
* Allow runtime to return more detailed transaction validation errors. * Re-use ApplyError codes and update test-runtime. * Fix pool tests. * Revert using Compact for validity.
This commit is contained in:
@@ -118,12 +118,12 @@ impl<B: ChainApi> Pool<B> {
|
||||
valid_till: block_number.as_().saturating_add(longevity),
|
||||
})
|
||||
},
|
||||
TransactionValidity::Invalid => {
|
||||
bail!(error::Error::from(error::ErrorKind::InvalidTransaction))
|
||||
TransactionValidity::Invalid(e) => {
|
||||
bail!(error::Error::from(error::ErrorKind::InvalidTransaction(e)))
|
||||
},
|
||||
TransactionValidity::Unknown => {
|
||||
TransactionValidity::Unknown(e) => {
|
||||
self.listener.write().invalid(&hash);
|
||||
bail!(error::Error::from(error::ErrorKind::UnknownTransactionValidity))
|
||||
bail!(error::Error::from(error::ErrorKind::UnknownTransactionValidity(e)))
|
||||
},
|
||||
}
|
||||
})
|
||||
@@ -247,7 +247,7 @@ impl<B: ChainApi> Pool<B> {
|
||||
// Collect the hashes of transactions that now became invalid (meaning that they are succesfuly pruned).
|
||||
let hashes = results.into_iter().enumerate().filter_map(|(idx, r)| match r.map_err(error::IntoPoolError::into_pool_error) {
|
||||
Err(Ok(err)) => match err.kind() {
|
||||
error::ErrorKind::InvalidTransaction => Some(hashes[idx].clone()),
|
||||
error::ErrorKind::InvalidTransaction(_) => Some(hashes[idx].clone()),
|
||||
_ => None,
|
||||
},
|
||||
_ => None,
|
||||
@@ -413,7 +413,7 @@ mod tests {
|
||||
let nonce = uxt.transfer().nonce;
|
||||
|
||||
if nonce < block_number {
|
||||
Ok(TransactionValidity::Invalid)
|
||||
Ok(TransactionValidity::Invalid(0))
|
||||
} else {
|
||||
Ok(TransactionValidity::Valid {
|
||||
priority: 4,
|
||||
|
||||
Reference in New Issue
Block a user