Use tokio instead of async-std (#495)

* examples: Use tokio instead of std async

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* test-runtime: Use tokio instead of std async

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* subxt: Use tokio instead of std async

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* examples: Use only necessary tokio features

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2022-04-01 17:57:15 +03:00
committed by GitHub
parent cc0b1ec84a
commit 6ce9983506
25 changed files with 69 additions and 69 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ use subxt::{
#[subxt::subxt(runtime_metadata_path = "examples/polkadot_metadata.scale")]
pub mod polkadot {}
#[async_std::main]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
@@ -38,7 +38,7 @@ use subxt::{
#[subxt::subxt(runtime_metadata_path = "examples/polkadot_metadata.scale")]
pub mod polkadot {}
#[async_std::main]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
+1 -1
View File
@@ -55,7 +55,7 @@ impl Config for MyConfig {
type Extrinsic = <DefaultConfig as Config>::Extrinsic;
}
#[async_std::main]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api = ClientBuilder::new()
.build()
+1 -1
View File
@@ -30,7 +30,7 @@ pub mod polkadot {}
use polkadot::runtime_types::frame_support::PalletId;
#[async_std::main]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let pallet_id = PalletId([1u8; 8]);
let _ = pallet_id.clone();
+1 -1
View File
@@ -31,7 +31,7 @@ use subxt::{
#[subxt::subxt(runtime_metadata_path = "examples/polkadot_metadata.scale")]
pub mod polkadot {}
#[async_std::main]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
+1 -1
View File
@@ -37,7 +37,7 @@ use subxt::{
#[subxt::subxt(runtime_metadata_path = "examples/polkadot_metadata.scale")]
pub mod polkadot {}
#[async_std::main]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
+1 -1
View File
@@ -31,7 +31,7 @@ use subxt::{
#[subxt::subxt(runtime_metadata_path = "examples/polkadot_metadata.scale")]
pub mod polkadot {}
#[async_std::main]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
+1 -1
View File
@@ -34,7 +34,7 @@ use subxt::{
#[subxt::subxt(runtime_metadata_path = "examples/polkadot_metadata.scale")]
pub mod polkadot {}
#[async_std::main]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
+3 -3
View File
@@ -37,7 +37,7 @@ pub mod polkadot {}
/// Subscribe to all events, and then manually look through them and
/// pluck out the events that we care about.
#[async_std::main]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
@@ -50,7 +50,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut event_sub = api.events().subscribe().await?;
// While this subscription is active, balance transfers are made somewhere:
async_std::task::spawn(async {
tokio::task::spawn(async {
let signer = PairSigner::new(AccountKeyring::Alice.pair());
let api =
ClientBuilder::new()
@@ -73,7 +73,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.await
.unwrap();
async_std::task::sleep(Duration::from_secs(10)).await;
tokio::time::sleep(Duration::from_secs(10)).await;
transfer_amount += 100_000_000;
}
});
+3 -3
View File
@@ -37,7 +37,7 @@ pub mod polkadot {}
/// Subscribe to all events, and then manually look through them and
/// pluck out the events that we care about.
#[async_std::main]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
@@ -56,7 +56,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.filter_events::<(polkadot::balances::events::Transfer,)>();
// While this subscription is active, we imagine some balance transfers are made somewhere else:
async_std::task::spawn(async {
tokio::task::spawn(async {
let signer = PairSigner::new(AccountKeyring::Alice.pair());
let api =
ClientBuilder::new()
@@ -76,7 +76,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.sign_and_submit_default(&signer)
.await
.unwrap();
async_std::task::sleep(Duration::from_secs(10)).await;
tokio::time::sleep(Duration::from_secs(10)).await;
}
});
+3 -3
View File
@@ -37,7 +37,7 @@ pub mod polkadot {}
/// Subscribe to all events, and then manually look through them and
/// pluck out the events that we care about.
#[async_std::main]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
@@ -57,7 +57,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
)>();
// While this subscription is active, we imagine some balance transfers are made somewhere else:
async_std::task::spawn(async {
tokio::task::spawn(async {
let signer = PairSigner::new(AccountKeyring::Alice.pair());
let api =
ClientBuilder::new()
@@ -77,7 +77,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.sign_and_submit_default(&signer)
.await
.unwrap();
async_std::task::sleep(Duration::from_secs(10)).await;
tokio::time::sleep(Duration::from_secs(10)).await;
}
});