mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 06:21:02 +00:00
ff342fafa9
Avoid duplicate function definitions for: - ensure_owner_or_root() - ensure_not_halted() - set_owner() - set_operating_mode() / set_operational() Signed-off-by: Serban Iorga <serban@parity.io>
112 lines
3.7 KiB
Rust
112 lines
3.7 KiB
Rust
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
|
// This file is part of Parity Bridges Common.
|
|
|
|
// Parity Bridges Common is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
|
|
// Parity Bridges Common is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//! The library of substrate relay. contains some public codes to provide to substrate relay.
|
|
|
|
#![warn(missing_docs)]
|
|
|
|
use std::time::Duration;
|
|
|
|
pub mod conversion_rate_update;
|
|
pub mod error;
|
|
pub mod finality;
|
|
pub mod helpers;
|
|
pub mod messages_lane;
|
|
pub mod messages_metrics;
|
|
pub mod messages_source;
|
|
pub mod messages_target;
|
|
pub mod on_demand;
|
|
pub mod parachains;
|
|
|
|
/// Default relay loop stall timeout. If transactions generated by relay are immortal, then
|
|
/// this timeout is used.
|
|
///
|
|
/// There are no any strict requirements on block time in Substrate. But we assume here that all
|
|
/// Substrate-based chains will be designed to produce relatively fast (compared to the slowest
|
|
/// blockchains) blocks. So 1 hour seems to be a good guess for (even congested) chains to mine
|
|
/// transaction, or remove it from the pool.
|
|
pub const STALL_TIMEOUT: Duration = Duration::from_secs(60 * 60);
|
|
|
|
/// Transaction creation parameters.
|
|
#[derive(Clone, Debug)]
|
|
pub struct TransactionParams<TS> {
|
|
/// Transactions author.
|
|
pub signer: TS,
|
|
/// Transactions mortality.
|
|
pub mortality: Option<u32>,
|
|
}
|
|
|
|
/// Tagged relay account, which balance may be exposed as metrics by the relay.
|
|
#[derive(Clone, Debug)]
|
|
pub enum TaggedAccount<AccountId> {
|
|
/// Account, used to sign headers relay transactions from given bridged chain.
|
|
Headers {
|
|
/// Account id.
|
|
id: AccountId,
|
|
/// Name of the bridged chain, which headers are relayed.
|
|
bridged_chain: String,
|
|
},
|
|
/// Account, used to sign parachains relay transactions from given bridged relay chain.
|
|
Parachains {
|
|
/// Account id.
|
|
id: AccountId,
|
|
/// Name of the bridged relay chain with parachain heads.
|
|
bridged_chain: String,
|
|
},
|
|
/// Account, used to sign message relay transactions from given bridged chain.
|
|
Messages {
|
|
/// Account id.
|
|
id: AccountId,
|
|
/// Name of the bridged chain, which sends us messages or delivery confirmations.
|
|
bridged_chain: String,
|
|
},
|
|
/// Account, used to sign messages with-bridged-chain pallet parameters update transactions.
|
|
MessagesPalletOwner {
|
|
/// Account id.
|
|
id: AccountId,
|
|
/// Name of the chain, bridged using messages pallet at our chain.
|
|
bridged_chain: String,
|
|
},
|
|
}
|
|
|
|
impl<AccountId> TaggedAccount<AccountId> {
|
|
/// Returns reference to the account id.
|
|
pub fn id(&self) -> &AccountId {
|
|
match *self {
|
|
TaggedAccount::Headers { ref id, .. } => id,
|
|
TaggedAccount::Parachains { ref id, .. } => id,
|
|
TaggedAccount::Messages { ref id, .. } => id,
|
|
TaggedAccount::MessagesPalletOwner { ref id, .. } => id,
|
|
}
|
|
}
|
|
|
|
/// Returns stringified account tag.
|
|
pub fn tag(&self) -> String {
|
|
match *self {
|
|
TaggedAccount::Headers { ref bridged_chain, .. } => format!("{}Headers", bridged_chain),
|
|
TaggedAccount::Parachains { ref bridged_chain, .. } => {
|
|
format!("{}Parachains", bridged_chain)
|
|
},
|
|
TaggedAccount::Messages { ref bridged_chain, .. } => {
|
|
format!("{}Messages", bridged_chain)
|
|
},
|
|
TaggedAccount::MessagesPalletOwner { ref bridged_chain, .. } => {
|
|
format!("{}MessagesPalletOwner", bridged_chain)
|
|
},
|
|
}
|
|
}
|
|
}
|