mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 12:11:09 +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
@@ -98,12 +98,15 @@ use codec::Decode;
|
||||
use inherents::ProvideInherentData;
|
||||
use support::{Parameter, decl_storage, decl_module};
|
||||
use support::traits::{Time, Get};
|
||||
use sr_primitives::traits::{
|
||||
SimpleArithmetic, Zero, SaturatedConversion, Scale
|
||||
use sr_primitives::{
|
||||
RuntimeString,
|
||||
traits::{
|
||||
SimpleArithmetic, Zero, SaturatedConversion, Scale
|
||||
}
|
||||
};
|
||||
use sr_primitives::weights::SimpleDispatchInfo;
|
||||
use system::ensure_none;
|
||||
use inherents::{RuntimeString, InherentIdentifier, ProvideInherent, IsFatalError, InherentData};
|
||||
use inherents::{InherentIdentifier, ProvideInherent, IsFatalError, InherentData};
|
||||
|
||||
/// The identifier for the `timestamp` inherent.
|
||||
pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"timstap0";
|
||||
@@ -145,11 +148,11 @@ impl InherentError {
|
||||
/// Auxiliary trait to extract timestamp inherent data.
|
||||
pub trait TimestampInherentData {
|
||||
/// Get timestamp inherent data.
|
||||
fn timestamp_inherent_data(&self) -> Result<InherentType, RuntimeString>;
|
||||
fn timestamp_inherent_data(&self) -> Result<InherentType, inherents::Error>;
|
||||
}
|
||||
|
||||
impl TimestampInherentData for InherentData {
|
||||
fn timestamp_inherent_data(&self) -> Result<InherentType, RuntimeString> {
|
||||
fn timestamp_inherent_data(&self) -> Result<InherentType, inherents::Error> {
|
||||
self.get_data(&INHERENT_IDENTIFIER)
|
||||
.and_then(|r| r.ok_or_else(|| "Timestamp inherent data not found".into()))
|
||||
}
|
||||
@@ -164,7 +167,10 @@ impl ProvideInherentData for InherentDataProvider {
|
||||
&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> {
|
||||
use std::time::SystemTime;
|
||||
|
||||
let now = SystemTime::now();
|
||||
|
||||
Reference in New Issue
Block a user