mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 06:21:11 +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
@@ -385,6 +385,33 @@ pub mod ext {
|
||||
/// - nonzero otherwise.
|
||||
fn ext_submit_transaction(data: *const u8, len: u32) -> u32;
|
||||
|
||||
/// Returns information about the local node's network state.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// The encoded `Result<offchain::OpaqueNetworkState, ()>`.
|
||||
/// `written_out` contains the length of the message.
|
||||
///
|
||||
/// The ownership of the returned buffer is transferred to the runtime
|
||||
/// code and the runtime is responsible for freeing it. This is always
|
||||
/// a properly allocated pointer (which cannot be NULL), hence the
|
||||
/// runtime code can always rely on it.
|
||||
fn ext_network_state(written_out: *mut u32) -> *mut u8;
|
||||
|
||||
/// Returns the locally configured authority public key, if available.
|
||||
/// The `crypto` argument is `offchain::CryptoKind` converted to `u32`.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// The encoded `Result<PublicKey encoded to Vec<u8>, ()>`.
|
||||
/// `written_out` contains the length of the message.
|
||||
///
|
||||
/// The ownership of the returned buffer is transferred to the runtime
|
||||
/// code and the runtime is responsible for freeing it. This is always
|
||||
/// a properly allocated pointer (which cannot be NULL), hence the
|
||||
/// runtime code can always rely on it.
|
||||
fn ext_authority_pubkey(crypto: u32, written_out: *mut u32) -> *mut u8;
|
||||
|
||||
/// Create new key(pair) for signing/encryption/decryption.
|
||||
///
|
||||
/// # Returns
|
||||
@@ -504,7 +531,7 @@ pub mod ext {
|
||||
/// - Otherwise, pointer to the value in memory. `value_len` contains the length of the value.
|
||||
fn ext_local_storage_get(kind: u32, key: *const u8, key_len: u32, value_len: *mut u32) -> *mut u8;
|
||||
|
||||
/// Initiaties a http request.
|
||||
/// Initiates a http request.
|
||||
///
|
||||
/// `meta` is parity-codec encoded additional parameters to the request (like redirection policy,
|
||||
/// timeouts, certificates policy, etc). The format is not yet specified and the field is currently
|
||||
@@ -888,6 +915,39 @@ impl OffchainApi for () {
|
||||
}
|
||||
}
|
||||
|
||||
fn network_state() -> Result<offchain::OpaqueNetworkState, ()> {
|
||||
let mut len = 0_u32;
|
||||
let raw_result = unsafe {
|
||||
let ptr = ext_network_state.get()(&mut len);
|
||||
|
||||
from_raw_parts(ptr, len)
|
||||
};
|
||||
|
||||
match raw_result {
|
||||
Some(raw_result) => codec::Decode::decode(&mut &*raw_result).unwrap_or(Err(())),
|
||||
None => Err(())
|
||||
}
|
||||
}
|
||||
|
||||
fn authority_pubkey(kind: offchain::CryptoKind) -> Result<Vec<u8>, ()> {
|
||||
let kind = kind as isize as u32;
|
||||
|
||||
let mut len = 0u32;
|
||||
let raw_result = unsafe {
|
||||
let ptr = ext_authority_pubkey.get()(
|
||||
kind,
|
||||
&mut len,
|
||||
);
|
||||
|
||||
from_raw_parts(ptr, len)
|
||||
};
|
||||
|
||||
match raw_result {
|
||||
Some(raw_result) => codec::Decode::decode(&mut &*raw_result).unwrap_or(Err(())),
|
||||
None => Err(())
|
||||
}
|
||||
}
|
||||
|
||||
fn new_crypto_key(crypto: offchain::CryptoKind) -> Result<offchain::CryptoKeyId, ()> {
|
||||
let crypto = crypto.into();
|
||||
let ret = unsafe {
|
||||
|
||||
Reference in New Issue
Block a user