mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 16:57:58 +00:00
transaction-pool: drop unpropagable txs if local node cant author blocks (#8048)
* transaction-pool: drop unpropagable txs if local node cant author blocks * fix test compilation * transaction-pool: remove unnecessary static bound on CanAuthor Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * rpc-api: add translation for PoolError::Unactionable * transaction-pool: add test for rejecting unactionable transactions * basic-authorship: fix doc test * transaction-pool: fix benchmark compilation * transaction-pool: rename CanAuthor to IsValidator * transaction-pool: nit in error message Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
@@ -99,6 +99,9 @@ const POOL_CYCLE_DETECTED: i64 = POOL_INVALID_TX + 5;
|
||||
const POOL_IMMEDIATELY_DROPPED: i64 = POOL_INVALID_TX + 6;
|
||||
/// The key type crypto is not known.
|
||||
const UNSUPPORTED_KEY_TYPE: i64 = POOL_INVALID_TX + 7;
|
||||
/// The transaction was not included to the pool since it is unactionable,
|
||||
/// it is not propagable and the local node does not author blocks.
|
||||
const POOL_UNACTIONABLE: i64 = POOL_INVALID_TX + 8;
|
||||
|
||||
impl From<Error> for rpc::Error {
|
||||
fn from(e: Error) -> Self {
|
||||
@@ -158,6 +161,14 @@ impl From<Error> for rpc::Error {
|
||||
message: "Immediately Dropped".into(),
|
||||
data: Some("The transaction couldn't enter the pool because of the limit".into()),
|
||||
},
|
||||
Error::Pool(PoolError::Unactionable) => rpc::Error {
|
||||
code: rpc::ErrorCode::ServerError(POOL_UNACTIONABLE),
|
||||
message: "Unactionable".into(),
|
||||
data: Some(
|
||||
"The transaction is unactionable since it is not propagable and \
|
||||
the local node does not author blocks".into(),
|
||||
),
|
||||
},
|
||||
Error::UnsupportedKeyType => rpc::Error {
|
||||
code: rpc::ErrorCode::ServerError(UNSUPPORTED_KEY_TYPE),
|
||||
message: "Unknown key type crypto" .into(),
|
||||
|
||||
Reference in New Issue
Block a user