mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 02:51:01 +00:00
86834e2fd6
* Implement public helpers for querying header info * Update `best_header` when importing headers * Add BestHeader to GenesisConfig * Define extra types for Millau primitives * Start implementing runtime APIs in Millau runtime * Add helper for getting headers which require a justification * Add runtime API for getting headers requiring a justification * Reword `expect()` proof for valid authority sets * Fix typo * Clean up Hasher comment * Add the Call Dispatch Pallet back to the Millau runtime * Use types from Rialto in bridge pallet config * Use the Rialto runtime APIS in the Millau runtime * Include Millau bridge instance in Rialto runtime * Add missing doc comment * Use one storage function for setting and clearing `RequiresJustification` * Remove TODO comments
63 lines
2.5 KiB
Rust
63 lines
2.5 KiB
Rust
// Copyright 2019-2020 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/>.
|
|
|
|
#![cfg_attr(not(feature = "std"), no_std)]
|
|
// RuntimeApi generated functions
|
|
#![allow(clippy::too_many_arguments)]
|
|
// Runtime-generated DecodeLimit::decode_all_With_depth_limit
|
|
#![allow(clippy::unnecessary_mut_passed)]
|
|
|
|
use sp_core::Hasher as HasherT;
|
|
use sp_runtime::traits::BlakeTwo256;
|
|
use sp_std::prelude::*;
|
|
|
|
/// Block number type used in Rialto.
|
|
pub type BlockNumber = u32;
|
|
|
|
/// Hash type used in Rialto.
|
|
pub type Hash = <BlakeTwo256 as HasherT>::Out;
|
|
|
|
/// The type of an object that can produce hashes on Rialto.
|
|
pub type Hasher = BlakeTwo256;
|
|
|
|
/// The header type used by Rialto.
|
|
pub type Header = sp_runtime::generic::Header<BlockNumber, Hasher>;
|
|
|
|
sp_api::decl_runtime_apis! {
|
|
/// API for querying information about Rialto headers from the Bridge Pallet instance.
|
|
///
|
|
/// This API is implemented by runtimes that are bridging with Rialto chain, not the
|
|
/// Rialto runtime itself.
|
|
pub trait RialtoHeaderApi {
|
|
/// Returns number and hash of the best block known to the bridge module.
|
|
///
|
|
/// The caller should only submit an `import_header` transaction that makes
|
|
/// (or leads to making) other header the best one.
|
|
fn best_block() -> (BlockNumber, Hash);
|
|
/// Returns number and hash of the best finalized block known to the bridge module.
|
|
fn finalized_block() -> (BlockNumber, Hash);
|
|
/// Returns numbers and hashes of headers that require finality proofs.
|
|
///
|
|
/// An empty response means that there are no headers which currently require a
|
|
/// finality proof.
|
|
fn incomplete_headers() -> Vec<(BlockNumber, Hash)>;
|
|
/// Returns true if the header is known to the runtime.
|
|
fn is_known_block(hash: Hash) -> bool;
|
|
/// Returns true if the header is considered finalized by the runtime.
|
|
fn is_finalized_block(hash: Hash) -> bool;
|
|
}
|
|
}
|