referrerpolicy=no-referrer-when-downgrade

frame_support/traits/
tx_pause.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//! Types to pause calls in the runtime.
19
20/// Can pause specific transactions from being processed.
21///
22/// Note that paused transactions will not be queued for later execution. Instead they will be
23/// dropped.
24pub trait TransactionPause {
25	/// How to unambiguously identify a call.
26	///
27	/// For example `(pallet_index, call_index)`.
28	type CallIdentifier;
29
30	/// Whether this call is paused.
31	fn is_paused(call: Self::CallIdentifier) -> bool;
32
33	/// Whether this call can be paused.
34	///
35	/// This holds for the current block, but may change in the future.
36	fn can_pause(call: Self::CallIdentifier) -> bool;
37
38	/// Pause this call immediately.
39	///
40	/// This takes effect in the same block and must succeed if `can_pause` returns `true`.
41	fn pause(call: Self::CallIdentifier) -> Result<(), TransactionPauseError>;
42
43	/// Unpause this call immediately.
44	///
45	/// This takes effect in the same block and must succeed if `is_paused` returns `true`. This
46	/// invariant is important to not have un-resumable calls.
47	fn unpause(call: Self::CallIdentifier) -> Result<(), TransactionPauseError>;
48}
49
50/// The error type for [`TransactionPause`].
51pub enum TransactionPauseError {
52	/// The call could not be found in the runtime.
53	///
54	/// This is a permanent error but could change after a runtime upgrade.
55	NotFound,
56	/// Call cannot be paused.
57	///
58	/// This may or may not resolve in a future block.
59	Unpausable,
60	/// Call is already paused.
61	AlreadyPaused,
62	/// Call is already unpaused.
63	AlreadyUnpaused,
64	/// Unknown error.
65	Unknown,
66}