// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program 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.
// This program 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 this program. If not, see .
//! Bizinikiwi blockchain API.
mod chain_full;
#[cfg(test)]
mod tests;
use std::sync::Arc;
use crate::SubscriptionTaskExecutor;
use jsonrpsee::{core::async_trait, PendingSubscriptionSink};
use pezsc_client_api::BlockchainEvents;
use pezsp_rpc::{list::ListOrValue, number::NumberOrHex};
use pezsp_runtime::{
generic::SignedBlock,
traits::{Block as BlockT, NumberFor},
};
use self::error::Error;
use pezsc_client_api::BlockBackend;
pub use pezsc_rpc_api::chain::*;
use pezsp_blockchain::HeaderBackend;
/// Blockchain backend API
#[async_trait]
trait ChainBackend: Send + Sync + 'static
where
Block: BlockT + 'static,
Block::Header: Unpin,
Client: HeaderBackend + BlockchainEvents + 'static,
{
/// Get client reference.
fn client(&self) -> &Arc;
/// Tries to unwrap passed block hash, or uses best block hash otherwise.
fn unwrap_or_best(&self, hash: Option) -> Block::Hash {
match hash {
None => self.client().info().best_hash,
Some(hash) => hash,
}
}
/// Get header of a block.
fn header(&self, hash: Option) -> Result