// 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 .
//! Storage queries for the RPC-V2 spec.
use std::{marker::PhantomData, sync::Arc};
use pezsc_client_api::{Backend, ChildInfo, StorageKey, StorageProvider};
use pezsp_runtime::traits::Block as BlockT;
use tokio::sync::mpsc;
use super::events::{StorageQuery, StorageQueryType, StorageResult, StorageResultType};
use crate::hex_string;
/// Call into the storage of blocks.
pub struct Storage {
/// Bizinikiwi client.
client: Arc,
_phandom: PhantomData<(BE, Block)>,
}
impl Clone for Storage {
fn clone(&self) -> Self {
Self { client: self.client.clone(), _phandom: PhantomData }
}
}
impl Storage {
/// Constructs a new [`Storage`].
pub fn new(client: Arc) -> Self {
Self { client, _phandom: PhantomData }
}
}
/// Query to iterate over storage.
#[derive(Debug)]
pub struct QueryIter {
/// The key from which the iteration was started.
pub query_key: StorageKey,
/// The key after which pagination should resume.
pub pagination_start_key: Option,
/// The type of the query (either value or hash).
pub ty: IterQueryType,
}
/// The query type of an iteration.
#[derive(Debug)]
pub enum IterQueryType {
/// Iterating over (key, value) pairs.
Value,
/// Iterating over (key, hash) pairs.
Hash,
}
/// The result of making a query call.
pub type QueryResult = Result