Skip to content

Commit

Permalink
fix: relay_compact_block_with_one_tx random failure
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangsoledad authored and doitian committed Nov 19, 2018
1 parent 40bb41d commit 131d7e1
Show file tree
Hide file tree
Showing 7 changed files with 779 additions and 35 deletions.
20 changes: 12 additions & 8 deletions network/src/ckb_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use protocol_service::ProtocolService;
use std::boxed::Box;
use std::io::{Error as IoError, ErrorKind as IoErrorKind};
use std::sync::Arc;
use tokio;

pub struct CKBService {
// used to update kbuckets
Expand Down Expand Up @@ -73,14 +74,17 @@ impl CKBService {
move |data| {
// update kad_system when we received data
kad_system.update_kbuckets(peer_id.clone());
protocol_handler.received(
Box::new(DefaultCKBProtocolContext::new(
Arc::clone(&network),
protocol_id,
)),
peer_index,
&data,
);
let protocol_handler = Arc::clone(&protocol_handler);
let network = Arc::clone(&network);
let handle_received = future::lazy(move || {
protocol_handler.received(
Box::new(DefaultCKBProtocolContext::new(network, protocol_id)),
peer_index,
&data,
);
Ok(())
});
tokio::spawn(handle_received);
Ok(())
}
});
Expand Down
5 changes: 2 additions & 3 deletions network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ mod timer_service;
mod transport;

pub use self::errors::{Error, ErrorKind};
pub use self::network::Network;
pub use self::network::SessionInfo;
pub use self::network::{Network, PeerInfo, SessionInfo};
pub use self::network_config::NetworkConfig;
pub use self::network_service::NetworkService;
pub use ckb_protocol::{CKBProtocol, CKBProtocols};
pub use ckb_protocol_handler::{CKBProtocolContext, CKBProtocolHandler, Severity};
pub use libp2p::{multiaddr::AddrComponent, Multiaddr, PeerId};
pub use libp2p::{core::Endpoint, multiaddr::AddrComponent, Multiaddr, PeerId};

pub type TimerToken = usize;
pub type ProtocolId = [u8; 3];
Expand Down
2 changes: 1 addition & 1 deletion sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub const POW_SPACE: u64 = 10_000; //10s
// behind headers chain.
pub const MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT: usize = 4;
pub const CHAIN_SYNC_TIMEOUT: u64 = 20 * 60 * 1000; // 20 minutes
pub const EVICTION_TEST_RESPONSE_TIME: u64 = 120 * 1000; // 2 minutes
pub const EVICTION_HEADERS_RESPONSE_TIME: u64 = 120 * 1000; // 2 minutes

#[derive(Debug, PartialEq, Clone, Eq)]
pub enum AcceptBlockError {
Expand Down
Loading

0 comments on commit 131d7e1

Please sign in to comment.