sp_transaction_pool/runtime_api.rs
1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! Tagged Transaction Queue Runtime API.
19
20use sp_runtime::{
21 traits::Block as BlockT,
22 transaction_validity::{TransactionSource, TransactionValidity},
23};
24
25sp_api::decl_runtime_apis! {
26 /// The `TaggedTransactionQueue` api trait for interfering with the transaction queue.
27 #[api_version(3)]
28 pub trait TaggedTransactionQueue {
29 /// Validate the transaction.
30 #[changed_in(2)]
31 fn validate_transaction(tx: <Block as BlockT>::Extrinsic) -> TransactionValidity;
32
33 /// Validate the transaction.
34 #[changed_in(3)]
35 fn validate_transaction(
36 source: TransactionSource,
37 tx: <Block as BlockT>::Extrinsic,
38 ) -> TransactionValidity;
39
40 /// Validate the transaction.
41 ///
42 /// This method is invoked by the transaction pool to learn details about given transaction.
43 /// The implementation should make sure to verify the correctness of the transaction
44 /// against current state. The given `block_hash` corresponds to the hash of the block
45 /// that is used as current state.
46 ///
47 /// Note that this call may be performed by the pool multiple times and transactions
48 /// might be verified in any possible order.
49 fn validate_transaction(
50 source: TransactionSource,
51 tx: <Block as BlockT>::Extrinsic,
52 block_hash: Block::Hash,
53 ) -> TransactionValidity;
54 }
55}