mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 09:51:10 +00:00
Refactor sr-api to not depend on client anymore (#4086)
* Refactor sr-api to not depend on client anymore * Fix benches * Apply suggestions from code review Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Apply suggestions from code review
This commit is contained in:
committed by
Benjamin Kampmann
parent
e26d1a0b3e
commit
2ecffa1cd0
@@ -29,10 +29,7 @@ use codec::{Encode, Decode};
|
||||
use system::ensure_none;
|
||||
use sr_primitives::traits::{Header as HeaderT, One, Zero};
|
||||
use sr_primitives::weights::SimpleDispatchInfo;
|
||||
use inherents::{
|
||||
RuntimeString, InherentIdentifier, ProvideInherent,
|
||||
InherentData, MakeFatalError,
|
||||
};
|
||||
use inherents::{InherentIdentifier, ProvideInherent, InherentData, MakeFatalError};
|
||||
|
||||
/// The identifier for the `uncles` inherent.
|
||||
pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"uncles00";
|
||||
@@ -40,11 +37,11 @@ pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"uncles00";
|
||||
/// Auxiliary trait to extract uncles inherent data.
|
||||
pub trait UnclesInherentData<H: Decode> {
|
||||
/// Get uncles.
|
||||
fn uncles(&self) -> Result<Vec<H>, RuntimeString>;
|
||||
fn uncles(&self) -> Result<Vec<H>, inherents::Error>;
|
||||
}
|
||||
|
||||
impl<H: Decode> UnclesInherentData<H> for InherentData {
|
||||
fn uncles(&self) -> Result<Vec<H>, RuntimeString> {
|
||||
fn uncles(&self) -> Result<Vec<H>, inherents::Error> {
|
||||
Ok(self.get_data(&INHERENT_IDENTIFIER)?.unwrap_or_default())
|
||||
}
|
||||
}
|
||||
@@ -71,7 +68,7 @@ where F: Fn() -> Vec<H>
|
||||
&INHERENT_IDENTIFIER
|
||||
}
|
||||
|
||||
fn provide_inherent_data(&self, inherent_data: &mut InherentData) -> Result<(), RuntimeString> {
|
||||
fn provide_inherent_data(&self, inherent_data: &mut InherentData) -> Result<(), inherents::Error> {
|
||||
let uncles = (self.inner)();
|
||||
if !uncles.is_empty() {
|
||||
inherent_data.put_data(INHERENT_IDENTIFIER, &uncles)
|
||||
|
||||
Reference in New Issue
Block a user