Skip to content

Commit

Permalink
fix: p2p rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
jjyr committed Mar 12, 2019
1 parent 5a15c6b commit 9cd7618
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
7 changes: 5 additions & 2 deletions network/src/network_service.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use crate::network::{CKBProtocols, Network};
use crate::protocol_handler::{CKBProtocolContext, DefaultCKBProtocolContext};
use crate::{errors::Error, CKBEvent, NetworkConfig, ProtocolId};
use crate::{
multiaddr::Multiaddr,
network::{CKBProtocols, Network},
PeerId,
};
use ckb_util::Mutex;
use futures::future::Future;
use futures::sync::mpsc::Receiver;
use futures::sync::oneshot;
use libp2p::{Multiaddr, PeerId};
use log::{debug, info};
use std::sync::Arc;
use std::thread;
Expand Down
10 changes: 5 additions & 5 deletions network/src/tests/peers_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,19 @@ fn test_accept_inbound_peer_eviction() {
peer.ping = Some(Duration::from_secs(0));
}

// to prevent time error, we set now to 10000s ago.
let now = Instant::now() - Duration::from_secs(10000);
// to prevent time error, we set now to 10ago.
let now = Instant::now() - Duration::from_secs(10);
// peers which most recently sent messages
for _ in 0..EVICTION_PROTECT_PEERS {
let peer_id = peers_iter.next().unwrap();
let mut peer = peers_registry.get_mut(&peer_id).unwrap();
peer.last_message_time = Some(now + Duration::from_secs(10000));
peer.last_message_time = Some(now + Duration::from_secs(10));
}
// protect 5 peers which have the longest connection time
for _ in 0..longest_connection_time_peers_count {
let peer_id = peers_iter.next().unwrap();
let mut peer = peers_registry.get_mut(&peer_id).unwrap();
peer.connected_time = now - Duration::from_secs(10000);
peer.connected_time = now - Duration::from_secs(10);
}
let mut new_peer_ids = (0..3).map(|_| random_peer_id()).collect::<Vec<_>>();
// setup 3 node and 1 reserved node from addr1
Expand Down Expand Up @@ -184,7 +184,7 @@ fn test_accept_inbound_peer_eviction() {
for peer_id in new_peer_ids {
let mut peer = peers_registry.get_mut(&peer_id).unwrap();
// push the connected_time to make sure peer is unprotect
peer.connected_time = now + Duration::from_secs(10000);
peer.connected_time = now + Duration::from_secs(10);
}
// should evict evict target
assert!(peers_registry.get(&evict_target).is_some());
Expand Down
4 changes: 0 additions & 4 deletions rpc/src/module/pool.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use ckb_core::transaction::{ProposalShortId, Transaction as CoreTransaction};
use ckb_network::NetworkService;
use ckb_protocol::RelayMessage;
use ckb_shared::index::ChainIndex;
use ckb_shared::shared::Shared;
use ckb_network::{NetworkService, ProtocolId};
use ckb_protocol::RelayMessage;
use ckb_shared::index::ChainIndex;
Expand Down
2 changes: 1 addition & 1 deletion src/cli/run_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::Setup;
use ckb_chain::chain::{ChainBuilder, ChainController};
use ckb_core::script::Script;
use ckb_db::diskdb::RocksDB;
use ckb_miner::{BlockAssembler, BlockAssemblerController};
use ckb_miner::BlockAssembler;
use ckb_network::futures::sync::mpsc::channel;
use ckb_network::CKBProtocol;
use ckb_network::NetworkConfig;
Expand Down

0 comments on commit 9cd7618

Please sign in to comment.