Skip to content

Commit 0424656

Browse files
authored
Merge pull request #3293 from Pana/bump/mio2
prepare for upgrading mio to 1.0
2 parents 5f0e894 + ccdc5a0 commit 0424656

File tree

22 files changed

+631
-90
lines changed

22 files changed

+631
-90
lines changed

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ async-trait = "0.1"
323323
tower = "0.4"
324324
pin-project = "1.0"
325325
mio = "0.6"
326+
mio-extras = "2.0.6"
326327
reqwest = "0.12"
327328

328329
# crypto & hash
@@ -356,6 +357,7 @@ log4rs = "1.3.0"
356357
env_logger = "0.11"
357358
lazy_static = "1.4"
358359
itertools = "0.14"
360+
lazycell = "1.3"
359361
once_cell = "1.21"
360362
byteorder = "1.5"
361363
strum = "0.26"

crates/cfxcore/core/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ futures = { workspace = true, features = ["compat"] }
2929
hashbrown = { workspace = true }
3030
hibitset = { workspace = true }
3131
itertools = { workspace = true }
32-
io = { workspace = true }
3332
jsonrpc-core = { workspace = true }
3433
keccak-hash = { workspace = true }
3534
kvdb = { workspace = true }

crates/cfxcore/core/src/light_protocol/handler/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use cfx_parameters::light::{
3636
};
3737
use cfx_types::H256;
3838
use diem_types::validator_config::{ConsensusPublicKey, ConsensusVRFPublicKey};
39-
use io::TimerToken;
4039
use network::{
4140
node_table::NodeId, service::ProtocolVersion, NetworkContext,
4241
NetworkProtocolHandler,
@@ -57,6 +56,8 @@ use sync::{
5756
};
5857
use throttling::token_bucket::TokenBucketManager;
5958

59+
type TimerToken = usize;
60+
6061
const SYNC_TIMER: TimerToken = 0;
6162
const REQUEST_CLEANUP_TIMER: TimerToken = 1;
6263
const LOG_STATISTICS_TIMER: TimerToken = 2;

crates/cfxcore/core/src/light_protocol/provider.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ use cfx_parameters::light::{
4646
};
4747
use cfx_types::H256;
4848
use diem_types::validator_config::{ConsensusPublicKey, ConsensusVRFPublicKey};
49-
use io::TimerToken;
5049
use malloc_size_of_derive::MallocSizeOf as DeriveMallocSizeOf;
5150
use network::{
5251
node_table::NodeId, service::ProtocolVersion,
@@ -65,6 +64,8 @@ use std::{
6564
};
6665
use throttling::token_bucket::{ThrottleResult, TokenBucketManager};
6766

67+
type TimerToken = usize;
68+
6869
const CHECK_PEER_HEARTBEAT_TIMER: TimerToken = 0;
6970

7071
#[derive(DeriveMallocSizeOf)]

crates/cfxcore/core/src/pos/protocol/sync_protocol.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use diem_types::{
1818
epoch_change::EpochChangeProof,
1919
validator_config::{ConsensusPublicKey, ConsensusVRFPublicKey},
2020
};
21-
use io::TimerToken;
2221
use network::{
2322
node_table::NodeId, service::ProtocolVersion, NetworkContext,
2423
NetworkProtocolHandler, NetworkService, UpdateNodeOperation,
@@ -47,6 +46,8 @@ use crate::{
4746

4847
use super::{HSB_PROTOCOL_ID, HSB_PROTOCOL_VERSION};
4948

49+
type TimerToken = usize;
50+
5051
#[derive(Default)]
5152
pub struct PeerState {
5253
id: NodeId,

crates/cfxcore/core/src/sync/synchronization_protocol_handler.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use cfx_internal_common::ChainIdParamsDeprecated;
3030
use cfx_parameters::{block::MAX_BLOCK_SIZE_IN_BYTES, sync::*};
3131
use cfx_types::H256;
3232
use diem_types::validator_config::{ConsensusPublicKey, ConsensusVRFPublicKey};
33-
use io::TimerToken;
3433
use malloc_size_of::{new_malloc_size_ops, MallocSizeOf};
3534
use malloc_size_of_derive::MallocSizeOf as DeriveMallocSizeOf;
3635
use metrics::{register_meter_with_group, Meter, MeterTimer};
@@ -64,6 +63,8 @@ lazy_static! {
6463
register_meter_with_group("timer", "sync:propagate_tx_timer");
6564
}
6665

66+
type TimerToken = usize;
67+
6768
const TX_TIMER: TimerToken = 0;
6869
const CHECK_REQUEST_TIMER: TimerToken = 1;
6970
const BLOCK_CACHE_GC_TIMER: TimerToken = 2;

crates/network/src/connection.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use log::{debug, trace};
1313
use metrics::{
1414
register_meter_with_group, Gauge, GaugeUsize, Histogram, Meter, Sample,
1515
};
16-
use mio::{tcp::*, *};
16+
use mio::{tcp::TcpStream, Poll, PollOpt, Ready, Token};
1717
use priority_send_queue::{PrioritySendQueue, SendQueuePriority};
1818
use serde::Deserialize;
1919
use serde_derive::Serialize;
@@ -590,7 +590,7 @@ impl PacketAssembler for PacketWithLenAssembler {
590590
#[cfg(test)]
591591
mod tests {
592592
use super::*;
593-
use crate::iolib::*;
593+
use crate::iolib::IoChannel;
594594
use mio::Ready;
595595
use std::{
596596
cmp,

crates/network/src/node_table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{ip_utils::*, AllowIP, Error, IpFilter};
66
use cfx_types::H512;
77
use cfx_util_macros::bail;
88
use enum_map::{Enum, EnumMap};
9-
use io::*;
9+
use io::StreamToken;
1010
use log::{debug, warn};
1111
use rand::{self, prelude::SliceRandom, Rng};
1212
use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream};

crates/network/src/service.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ use std::{
1616
};
1717

1818
use keccak_hash::keccak;
19-
use mio::{tcp::*, udp::*, *};
19+
use mio::{
20+
tcp::{TcpListener, TcpStream},
21+
udp::UdpSocket,
22+
Poll, PollOpt, Ready, Token,
23+
};
2024
use parity_path::restrict_permissions_owner;
2125
use parking_lot::{Mutex, RwLock};
2226
use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream};
@@ -41,7 +45,7 @@ use serde::{Deserialize, Serialize};
4145
use crate::{
4246
discovery::Discovery,
4347
handshake::BYPASS_CRYPTOGRAPHY,
44-
iolib::*,
48+
iolib::{IoContext, IoHandler, IoService, StreamToken, TimerToken},
4549
ip_utils::{map_external_address, select_public_address},
4650
node_database::NodeDatabase,
4751
node_table::*,

0 commit comments

Comments
 (0)