mirror of
https://github.com/serai-dex/serai.git
synced 2024-11-16 17:07:35 +00:00
Downscope usage of futures
This commit is contained in:
parent
32bea92742
commit
6caf45ea1d
12 changed files with 26 additions and 22 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -4306,6 +4306,7 @@ dependencies = [
|
|||
name = "monero-serai"
|
||||
version = "0.1.4-alpha"
|
||||
dependencies = [
|
||||
"async-lock",
|
||||
"async-trait",
|
||||
"base58-monero",
|
||||
"curve25519-dalek",
|
||||
|
@ -4313,7 +4314,6 @@ dependencies = [
|
|||
"digest_auth",
|
||||
"dleq",
|
||||
"flexible-transcript",
|
||||
"futures",
|
||||
"group",
|
||||
"hex",
|
||||
"hex-literal",
|
||||
|
@ -7337,7 +7337,7 @@ dependencies = [
|
|||
"env_logger",
|
||||
"flexible-transcript",
|
||||
"frost-schnorrkel",
|
||||
"futures",
|
||||
"futures-util",
|
||||
"hex",
|
||||
"libp2p",
|
||||
"log",
|
||||
|
@ -8981,7 +8981,8 @@ name = "tendermint-machine"
|
|||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"futures",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"hex",
|
||||
"log",
|
||||
"parity-scale-codec",
|
||||
|
@ -9400,7 +9401,8 @@ dependencies = [
|
|||
"blake2",
|
||||
"ciphersuite",
|
||||
"flexible-transcript",
|
||||
"futures",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"hex",
|
||||
"log",
|
||||
"parity-scale-codec",
|
||||
|
|
|
@ -45,7 +45,7 @@ frost = { package = "modular-frost", path = "../../crypto/frost", version = "0.8
|
|||
|
||||
monero-generators = { path = "generators", version = "0.4", default-features = false }
|
||||
|
||||
futures = { version = "0.3", default-features = false, features = ["alloc"], optional = true }
|
||||
async-lock = { version = "3", default-features = false, optional = true }
|
||||
|
||||
hex-literal = "0.4"
|
||||
hex = { version = "0.4", default-features = false, features = ["alloc"] }
|
||||
|
@ -92,7 +92,7 @@ std = [
|
|||
|
||||
"monero-generators/std",
|
||||
|
||||
"futures?/std",
|
||||
"async-lock?/std",
|
||||
|
||||
"hex/std",
|
||||
"serde/std",
|
||||
|
@ -101,7 +101,7 @@ std = [
|
|||
"base58-monero/std",
|
||||
]
|
||||
|
||||
cache-distribution = ["futures"]
|
||||
cache-distribution = ["async-lock"]
|
||||
http-rpc = ["digest_auth", "simple-request", "tokio"]
|
||||
multisig = ["transcript", "frost", "dleq", "std"]
|
||||
binaries = ["tokio/rt-multi-thread", "tokio/macros", "http-rpc"]
|
||||
|
|
|
@ -6,7 +6,7 @@ use std_shims::sync::OnceLock;
|
|||
#[cfg(all(feature = "cache-distribution", not(feature = "std")))]
|
||||
use std_shims::sync::Mutex;
|
||||
#[cfg(all(feature = "cache-distribution", feature = "std"))]
|
||||
use futures::lock::Mutex;
|
||||
use async_lock::Mutex;
|
||||
|
||||
use zeroize::{Zeroize, ZeroizeOnDrop};
|
||||
|
||||
|
|
|
@ -46,12 +46,11 @@ borsh = { version = "1", default-features = false, features = ["std", "derive",
|
|||
log = { version = "0.4", default-features = false, features = ["std"] }
|
||||
env_logger = { version = "0.10", default-features = false, features = ["humantime"] }
|
||||
|
||||
futures = { version = "0.3", default-features = false, features = ["std"] }
|
||||
tokio = { version = "1", default-features = false, features = ["rt-multi-thread", "sync", "time", "macros"] }
|
||||
libp2p = { version = "0.52", default-features = false, features = ["tokio", "tcp", "noise", "yamux", "gossipsub", "mdns", "macros"] }
|
||||
|
||||
[dev-dependencies]
|
||||
futures = { version = "0.3", default-features = false, features = ["std"] }
|
||||
futures-util = { version = "0.3", default-features = false, features = ["std"] }
|
||||
tributary = { package = "tributary-chain", path = "./tributary", features = ["tests"] }
|
||||
sp-application-crypto = { git = "https://github.com/serai-dex/substrate", default-features = false, features = ["std"] }
|
||||
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false, features = ["std"] }
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::{
|
|||
|
||||
use zeroize::Zeroizing;
|
||||
use rand_core::{RngCore, CryptoRng, OsRng};
|
||||
use futures::{task::Poll, poll};
|
||||
use futures_util::{task::Poll, poll};
|
||||
|
||||
use ciphersuite::{
|
||||
group::{ff::Field, GroupEncoding},
|
||||
|
|
|
@ -29,7 +29,8 @@ log = { version = "0.4", default-features = false, features = ["std"] }
|
|||
serai-db = { path = "../../common/db" }
|
||||
|
||||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["std", "derive"] }
|
||||
futures = { version = "0.3", default-features = false, features = ["std"] }
|
||||
futures-util = { version = "0.3", default-features = false, features = ["std", "sink", "channel"] }
|
||||
futures-channel = { version = "0.3", default-features = false, features = ["std", "sink"] }
|
||||
tendermint = { package = "tendermint-machine", path = "./tendermint" }
|
||||
|
||||
tokio = { version = "1", default-features = false, features = ["sync", "time", "rt"] }
|
||||
|
|
|
@ -8,7 +8,8 @@ use zeroize::Zeroizing;
|
|||
use ciphersuite::{Ciphersuite, Ristretto};
|
||||
|
||||
use scale::Decode;
|
||||
use futures::{StreamExt, SinkExt, channel::mpsc::UnboundedReceiver};
|
||||
use futures_channel::mpsc::UnboundedReceiver;
|
||||
use futures_util::{StreamExt, SinkExt};
|
||||
use ::tendermint::{
|
||||
ext::{BlockNumber, Commit, Block as BlockTrait, Network},
|
||||
SignedMessageFor, SyncedBlock, SyncedBlockSender, SyncedBlockResultReceiver, MessageSender,
|
||||
|
|
|
@ -16,7 +16,8 @@ log = { version = "0.4", default-features = false, features = ["std"] }
|
|||
|
||||
parity-scale-codec = { version = "3", default-features = false, features = ["std", "derive"] }
|
||||
|
||||
futures = { version = "0.3", default-features = false, features = ["std", "async-await"] }
|
||||
futures-util = { version = "0.3", default-features = false, features = ["std", "async-await-macro", "sink", "channel"] }
|
||||
futures-channel = { version = "0.3", default-features = false, features = ["std", "sink"] }
|
||||
tokio = { version = "1", default-features = false, features = ["time"] }
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -8,10 +8,10 @@ use std::{
|
|||
|
||||
use parity_scale_codec::{Encode, Decode};
|
||||
|
||||
use futures::{
|
||||
use futures_channel::mpsc;
|
||||
use futures_util::{
|
||||
FutureExt, StreamExt, SinkExt,
|
||||
future::{self, Fuse},
|
||||
channel::mpsc,
|
||||
};
|
||||
use tokio::time::sleep;
|
||||
|
||||
|
@ -367,7 +367,7 @@ impl<N: Network + 'static> TendermintMachine<N> {
|
|||
let mut queue_future =
|
||||
if self.queue.is_empty() { Fuse::terminated() } else { future::ready(()).fuse() };
|
||||
|
||||
if let Some((our_message, msg, mut sig)) = futures::select_biased! {
|
||||
if let Some((our_message, msg, mut sig)) = futures_util::select_biased! {
|
||||
// Handle a new block occurring externally (an external sync loop)
|
||||
// Has the highest priority as it makes all other futures here irrelevant
|
||||
msg = self.synced_block_recv.next() => {
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::{
|
|||
collections::HashMap,
|
||||
};
|
||||
|
||||
use futures::{FutureExt, future};
|
||||
use futures_util::{FutureExt, future};
|
||||
use tokio::time::sleep;
|
||||
|
||||
use crate::{
|
||||
|
@ -80,9 +80,9 @@ impl<N: Network> RoundData<N> {
|
|||
let propose_timeout = timeout_future(Step::Propose);
|
||||
let prevote_timeout = timeout_future(Step::Prevote);
|
||||
let precommit_timeout = timeout_future(Step::Precommit);
|
||||
futures::pin_mut!(propose_timeout, prevote_timeout, precommit_timeout);
|
||||
futures_util::pin_mut!(propose_timeout, prevote_timeout, precommit_timeout);
|
||||
|
||||
futures::select_biased! {
|
||||
futures_util::select_biased! {
|
||||
step = propose_timeout => step,
|
||||
step = prevote_timeout => step,
|
||||
step = precommit_timeout => step,
|
||||
|
|
|
@ -7,7 +7,7 @@ use async_trait::async_trait;
|
|||
|
||||
use parity_scale_codec::{Encode, Decode};
|
||||
|
||||
use futures::SinkExt;
|
||||
use futures_util::sink::SinkExt;
|
||||
use tokio::{sync::RwLock, time::sleep};
|
||||
|
||||
use tendermint_machine::{
|
||||
|
|
|
@ -33,4 +33,4 @@ dkg = { path = "../../crypto/dkg", default-features = false }
|
|||
bitcoin-serai = { path = "../../coins/bitcoin", default-features = false, features = ["hazmat"] }
|
||||
|
||||
monero-generators = { path = "../../coins/monero/generators", default-features = false }
|
||||
monero-serai = { path = "../../coins/monero", default-features = false }
|
||||
monero-serai = { path = "../../coins/monero", default-features = false, features = ["cache-distribution"] }
|
||||
|
|
Loading…
Reference in a new issue