mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 21:41:12 +00:00
Introduce srml/im-online (#3079)
* Fix grammar and typo * Extend network service * Extend offchain API * Support creating unsigned UncheckedExtrinsic * Introduce srml/im-online * Bump impl and spec version * Fix web-wasm test * Apply suggestions from code review Remove parity-multiaddr dependency Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com> * Replace transmute with from_raw_parts * Replace PeerId.to_string() with .to_base58() Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com> * Update Cargo.lock * Bump impl and spec version (again) It was updated in master in the meantime. * Apply suggestions from code review Co-Authored-By: Sergei Pepyakin <sergei@parity.io> * Address comments * Add public function is_online_in_current_session() * Bump spec_version * Fix doc tests * Improve comments * Remove superfluous line * Name parameters consistently * Implement comments * Switch From to TryFrom * Use Vec instead of HashSet * Fix tests * Revert me: local testing * Fix check if already sent during session We gossip each session, hence we need to check if already sent in this session (not era). * Fix typos * Consistent terminology * Revert "Revert me: local testing" This reverts commit 73fbc29ff3e5ed71d99436318260b4f007e837f4. * Introduce IsMember trait * Implement misc comments * Remove unused function * Fix test * Fix external_addresses being written * Fix test * Add necessary trait bound * Do not increment version * Update lib.rs
This commit is contained in:
committed by
Gavin Wood
parent
a757dfb222
commit
c70b81444a
@@ -114,9 +114,15 @@ impl<
|
||||
Signature: Codec,
|
||||
Call,
|
||||
> Extrinsic for UncheckedExtrinsic<Address, Index, Call, Signature> {
|
||||
type Call = Call;
|
||||
|
||||
fn is_signed(&self) -> Option<bool> {
|
||||
Some(self.signature.is_some())
|
||||
}
|
||||
|
||||
fn new_unsigned(call: Self::Call) -> Option<Self> {
|
||||
Some(UncheckedExtrinsic::new_unsigned(call))
|
||||
}
|
||||
}
|
||||
|
||||
impl<Address: Codec, Index: HasCompact + Codec, Signature: Codec, Call: Decode> Decode
|
||||
|
||||
@@ -59,9 +59,15 @@ impl<Address, Index, Call, Signature> UncheckedMortalCompactExtrinsic<Address, I
|
||||
}
|
||||
|
||||
impl<Address: Encode, Index: Encode, Call: Encode, Signature: Encode> Extrinsic for UncheckedMortalCompactExtrinsic<Address, Index, Call, Signature> {
|
||||
type Call = Call;
|
||||
|
||||
fn is_signed(&self) -> Option<bool> {
|
||||
Some(self.signature.is_some())
|
||||
}
|
||||
|
||||
fn new_unsigned(call: Self::Call) -> Option<Self> {
|
||||
Some(UncheckedMortalCompactExtrinsic::new_unsigned(call))
|
||||
}
|
||||
}
|
||||
|
||||
impl<Address, AccountId, Index, Call, Signature, Context, Hash, BlockNumber> Checkable<Context>
|
||||
|
||||
@@ -61,9 +61,15 @@ impl<Address, Index, Call, Signature> UncheckedMortalExtrinsic<Address, Index, C
|
||||
}
|
||||
|
||||
impl<Address: Encode, Index: Encode, Call: Encode, Signature: Encode> Extrinsic for UncheckedMortalExtrinsic<Address, Index, Call, Signature> {
|
||||
type Call = Call;
|
||||
|
||||
fn is_signed(&self) -> Option<bool> {
|
||||
Some(self.signature.is_some())
|
||||
}
|
||||
|
||||
fn new_unsigned(call: Self::Call) -> Option<Self> {
|
||||
Some(UncheckedMortalExtrinsic::new_unsigned(call))
|
||||
}
|
||||
}
|
||||
|
||||
impl<Address, AccountId, Index, Call, Signature, Context, Hash, BlockNumber> Checkable<Context>
|
||||
|
||||
@@ -869,9 +869,13 @@ impl ::serde::Serialize for OpaqueExtrinsic {
|
||||
}
|
||||
|
||||
impl traits::Extrinsic for OpaqueExtrinsic {
|
||||
type Call = ();
|
||||
|
||||
fn is_signed(&self) -> Option<bool> {
|
||||
None
|
||||
}
|
||||
|
||||
fn new_unsigned(_call: Self::Call) -> Option<Self> { None }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -44,6 +44,14 @@ impl TypedKey for UintAuthorityId {
|
||||
const KEY_TYPE: KeyTypeId = UINT_DUMMY_KEY;
|
||||
}
|
||||
|
||||
impl AsRef<[u8]> for UintAuthorityId {
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
let ptr = self.0 as *const _;
|
||||
// It's safe to do this here since `UintAuthorityId` is `u64`.
|
||||
unsafe { std::slice::from_raw_parts(ptr, 8) }
|
||||
}
|
||||
}
|
||||
|
||||
impl OpaqueKeys for UintAuthorityId {
|
||||
type KeyTypeIds = std::iter::Cloned<std::slice::Iter<'static, KeyTypeId>>;
|
||||
|
||||
@@ -133,6 +141,8 @@ impl<'a> Deserialize<'a> for Header {
|
||||
pub struct ExtrinsicWrapper<Xt>(Xt);
|
||||
|
||||
impl<Xt> traits::Extrinsic for ExtrinsicWrapper<Xt> {
|
||||
type Call = ();
|
||||
|
||||
fn is_signed(&self) -> Option<bool> {
|
||||
None
|
||||
}
|
||||
@@ -219,6 +229,8 @@ impl<Call: Codec + Sync + Send, Context> Checkable<Context> for TestXt<Call> {
|
||||
fn check(self, _: &Context) -> Result<Self::Checked, &'static str> { Ok(self) }
|
||||
}
|
||||
impl<Call: Codec + Sync + Send> traits::Extrinsic for TestXt<Call> {
|
||||
type Call = Call;
|
||||
|
||||
fn is_signed(&self) -> Option<bool> {
|
||||
Some(self.0.is_some())
|
||||
}
|
||||
|
||||
@@ -622,6 +622,12 @@ pub trait RandomnessBeacon {
|
||||
pub trait Member: Send + Sync + Sized + MaybeDebug + Eq + PartialEq + Clone + 'static {}
|
||||
impl<T: Send + Sync + Sized + MaybeDebug + Eq + PartialEq + Clone + 'static> Member for T {}
|
||||
|
||||
/// Determine if a `MemberId` is a valid member.
|
||||
pub trait IsMember<MemberId> {
|
||||
/// Is the given `MemberId` a valid member?
|
||||
fn is_member(member_id: &MemberId) -> bool;
|
||||
}
|
||||
|
||||
/// Something which fulfills the abstract idea of a Substrate header. It has types for a `Number`,
|
||||
/// a `Hash` and a `Digest`. It provides access to an `extrinsics_root`, `state_root` and
|
||||
/// `parent_hash`, as well as a `digest` and a block `number`.
|
||||
@@ -702,10 +708,16 @@ pub trait Block: Clone + Send + Sync + Codec + Eq + MaybeSerializeDebugButNotDes
|
||||
}
|
||||
|
||||
/// Something that acts like an `Extrinsic`.
|
||||
pub trait Extrinsic {
|
||||
pub trait Extrinsic: Sized {
|
||||
/// The function call.
|
||||
type Call;
|
||||
|
||||
/// Is this `Extrinsic` signed?
|
||||
/// If no information are available about signed/unsigned, `None` should be returned.
|
||||
fn is_signed(&self) -> Option<bool> { None }
|
||||
|
||||
/// New instance of an unsigned extrinsic aka "inherent".
|
||||
fn new_unsigned(_call: Self::Call) -> Option<Self> { None }
|
||||
}
|
||||
|
||||
/// Extract the hashing type for a block.
|
||||
|
||||
Reference in New Issue
Block a user