mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-01 01:01:01 +00:00
Update exit-future and make sc-cli compile on wasm (#4289)
* updated exit-future (github repo) * Switch to broadcast crate * Migrate client/cli * Switch exit-future to modernize branch * Small changes * Switch to cargo version and fix fg tests * Revert "Small changes" This reverts commit a488106805d220cb4aee9e46a71481424c6d87d5.
This commit is contained in:
@@ -289,7 +289,7 @@ impl<B: BlockT, N: Network<B>> NetworkBridge<B, N> {
|
||||
service: N,
|
||||
config: crate::Config,
|
||||
set_state: crate::environment::SharedVoterSetState<B>,
|
||||
on_exit: impl Future<Item = (), Error = ()> + Clone + Send + 'static,
|
||||
on_exit: impl futures03::Future<Output = ()> + Clone + Send + Unpin + 'static,
|
||||
) -> (
|
||||
Self,
|
||||
impl Future<Item = (), Error = ()> + Send + 'static,
|
||||
@@ -350,9 +350,20 @@ impl<B: BlockT, N: Network<B>> NetworkBridge<B, N> {
|
||||
// lazily spawn these jobs onto their own tasks. the lazy future has access
|
||||
// to tokio globals, which aren't available outside.
|
||||
let mut executor = tokio_executor::DefaultExecutor::current();
|
||||
executor.spawn(Box::new(rebroadcast_job.select(on_exit.clone()).then(|_| Ok(()))))
|
||||
|
||||
use futures03::{FutureExt, TryFutureExt};
|
||||
|
||||
let rebroadcast_job = rebroadcast_job
|
||||
.select(on_exit.clone().map(Ok).compat())
|
||||
.then(|_| Ok(()));
|
||||
|
||||
let reporting_job = reporting_job
|
||||
.select(on_exit.clone().map(Ok).compat())
|
||||
.then(|_| Ok(()));
|
||||
|
||||
executor.spawn(Box::new(rebroadcast_job))
|
||||
.expect("failed to spawn grandpa rebroadcast job task");
|
||||
executor.spawn(Box::new(reporting_job.select(on_exit.clone()).then(|_| Ok(()))))
|
||||
executor.spawn(Box::new(reporting_job))
|
||||
.expect("failed to spawn grandpa reporting job task");
|
||||
Ok(())
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@ use std::sync::Arc;
|
||||
use keyring::Ed25519Keyring;
|
||||
use codec::Encode;
|
||||
use sp_runtime::traits::NumberFor;
|
||||
|
||||
use std::{pin::Pin, task::{Context, Poll}};
|
||||
use crate::environment::SharedVoterSetState;
|
||||
use fg_primitives::AuthorityList;
|
||||
use super::gossip::{self, GossipValidator};
|
||||
@@ -175,12 +175,11 @@ fn make_test_network() -> (
|
||||
#[derive(Clone)]
|
||||
struct Exit;
|
||||
|
||||
impl Future for Exit {
|
||||
type Item = ();
|
||||
type Error = ();
|
||||
impl futures03::Future for Exit {
|
||||
type Output = ();
|
||||
|
||||
fn poll(&mut self) -> Poll<(), ()> {
|
||||
Ok(Async::NotReady)
|
||||
fn poll(self: Pin<&mut Self>, _: &mut Context) -> Poll<()> {
|
||||
Poll::Pending
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -555,7 +555,7 @@ pub fn run_grandpa_voter<B, E, Block: BlockT<Hash=H256>, N, RA, SC, VR, X>(
|
||||
NumberFor<Block>: BlockNumberOps,
|
||||
DigestFor<Block>: Encode,
|
||||
RA: Send + Sync + 'static,
|
||||
X: Future<Item=(),Error=()> + Clone + Send + 'static,
|
||||
X: futures03::Future<Output=()> + Clone + Send + Unpin + 'static,
|
||||
{
|
||||
let GrandpaParams {
|
||||
config,
|
||||
@@ -634,7 +634,9 @@ pub fn run_grandpa_voter<B, E, Block: BlockT<Hash=H256>, N, RA, SC, VR, X>(
|
||||
let telemetry_task = telemetry_task
|
||||
.then(|_| futures::future::empty::<(), ()>());
|
||||
|
||||
Ok(voter_work.select(on_exit).select2(telemetry_task).then(|_| Ok(())))
|
||||
use futures03::{FutureExt, TryFutureExt};
|
||||
|
||||
Ok(voter_work.select(on_exit.map(Ok).compat()).select2(telemetry_task).then(|_| Ok(())))
|
||||
}
|
||||
|
||||
/// Future that powers the voter.
|
||||
@@ -889,7 +891,7 @@ pub fn run_grandpa<B, E, Block: BlockT<Hash=H256>, N, RA, SC, VR, X>(
|
||||
DigestFor<Block>: Encode,
|
||||
RA: Send + Sync + 'static,
|
||||
VR: VotingRule<Block, Client<B, E, Block, RA>> + Clone + 'static,
|
||||
X: Future<Item=(),Error=()> + Clone + Send + 'static,
|
||||
X: futures03::Future<Output=()> + Clone + Send + Unpin + 'static,
|
||||
{
|
||||
run_grandpa_voter(grandpa_params)
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ pub fn run_grandpa_observer<B, E, Block: BlockT<Hash=H256>, N, RA, SC>(
|
||||
config: Config,
|
||||
link: LinkHalf<B, E, Block, RA, SC>,
|
||||
network: N,
|
||||
on_exit: impl Future<Item=(),Error=()> + Clone + Send + 'static,
|
||||
on_exit: impl futures03::Future<Output=()> + Clone + Send + Unpin + 'static,
|
||||
) -> ::sp_blockchain::Result<impl Future<Item=(),Error=()> + Send + 'static> where
|
||||
B: Backend<Block, Blake2Hasher> + 'static,
|
||||
E: CallExecutor<Block, Blake2Hasher> + Send + Sync + 'static,
|
||||
@@ -195,7 +195,9 @@ pub fn run_grandpa_observer<B, E, Block: BlockT<Hash=H256>, N, RA, SC>(
|
||||
|
||||
let observer_work = network_startup.and_then(move |()| observer_work);
|
||||
|
||||
Ok(observer_work.select(on_exit).map(|_| ()).map_err(|_| ()))
|
||||
use futures03::{FutureExt, TryFutureExt};
|
||||
|
||||
Ok(observer_work.select(on_exit.map(Ok).compat()).map(|_| ()).map_err(|_| ()))
|
||||
}
|
||||
|
||||
/// Future that powers the observer.
|
||||
|
||||
@@ -39,6 +39,7 @@ use sp_runtime::generic::{BlockId, DigestItem};
|
||||
use primitives::{NativeOrEncoded, ExecutionContext, crypto::Public};
|
||||
use fg_primitives::{GRANDPA_ENGINE_ID, AuthorityList, GrandpaApi};
|
||||
use state_machine::{backend::InMemory, prove_read, read_proof_check};
|
||||
use std::{pin::Pin, task};
|
||||
|
||||
use authorities::AuthoritySet;
|
||||
use finality_proof::{FinalityProofProvider, AuthoritySetForFinalityProver, AuthoritySetForFinalityChecker};
|
||||
@@ -175,12 +176,11 @@ impl TestNetFactory for GrandpaTestNet {
|
||||
#[derive(Clone)]
|
||||
struct Exit;
|
||||
|
||||
impl Future for Exit {
|
||||
type Item = ();
|
||||
type Error = ();
|
||||
impl futures03::Future for Exit {
|
||||
type Output = ();
|
||||
|
||||
fn poll(&mut self) -> Poll<(), ()> {
|
||||
Ok(Async::NotReady)
|
||||
fn poll(self: Pin<&mut Self>, _: &mut task::Context) -> task::Poll<()> {
|
||||
task::Poll::Pending
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user