Abstract devp2p (#8048)
* Rename ethcore-network to ethcore-network-devp2p * Fix typo * Extract generic traits into util/network * Simplify util/network * Fix devp2p tests * Remove old feature * Fix RPC tests
This commit is contained in:
@@ -18,8 +18,9 @@ use std::sync::Arc;
|
||||
use std::collections::{HashMap, BTreeMap};
|
||||
use std::io;
|
||||
use bytes::Bytes;
|
||||
use network::{NetworkProtocolHandler, NetworkService, NetworkContext, HostInfo, PeerId, ProtocolId,
|
||||
NetworkConfiguration as BasicNetworkConfiguration, NonReservedPeerMode, Error, ErrorKind, ConnectionFilter};
|
||||
use devp2p::{NetworkService, ConnectionFilter};
|
||||
use network::{NetworkProtocolHandler, NetworkContext, HostInfo, PeerId, ProtocolId,
|
||||
NetworkConfiguration as BasicNetworkConfiguration, NonReservedPeerMode, Error, ErrorKind};
|
||||
use ethereum_types::{H256, H512, U256};
|
||||
use io::{TimerToken};
|
||||
use ethcore::ethstore::ethkey::Secret;
|
||||
@@ -393,7 +394,7 @@ impl ChainNotify for EthSync {
|
||||
};
|
||||
|
||||
let chain_info = self.eth_handler.chain.chain_info();
|
||||
light_proto.make_announcement(context, Announcement {
|
||||
light_proto.make_announcement(&context, Announcement {
|
||||
head_hash: chain_info.best_block_hash,
|
||||
head_num: chain_info.best_block_number,
|
||||
head_td: chain_info.total_difficulty,
|
||||
@@ -737,7 +738,7 @@ impl LightSync {
|
||||
{
|
||||
self.network.with_context_eval(
|
||||
self.subprotocol_name,
|
||||
move |ctx| self.proto.with_context(ctx, f),
|
||||
move |ctx| self.proto.with_context(&ctx, f),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
//!
|
||||
|
||||
extern crate ethcore_network as network;
|
||||
extern crate ethcore_network_devp2p as devp2p;
|
||||
extern crate ethcore_bytes as bytes;
|
||||
extern crate ethcore_io as io;
|
||||
extern crate ethcore_transaction as transaction;
|
||||
@@ -68,4 +69,5 @@ mod api;
|
||||
|
||||
pub use api::*;
|
||||
pub use chain::{SyncStatus, SyncState};
|
||||
pub use network::{validate_node_url, NonReservedPeerMode, Error, ErrorKind, ConnectionFilter, ConnectionDirection};
|
||||
pub use devp2p::{validate_node_url, ConnectionFilter, ConnectionDirection};
|
||||
pub use network::{NonReservedPeerMode, Error, ErrorKind};
|
||||
|
||||
@@ -61,19 +61,19 @@ pub trait SyncIo {
|
||||
}
|
||||
|
||||
/// Wraps `NetworkContext` and the blockchain client
|
||||
pub struct NetSyncIo<'s, 'h> where 'h: 's {
|
||||
network: &'s NetworkContext<'h>,
|
||||
pub struct NetSyncIo<'s> {
|
||||
network: &'s NetworkContext,
|
||||
chain: &'s BlockChainClient,
|
||||
snapshot_service: &'s SnapshotService,
|
||||
chain_overlay: &'s RwLock<HashMap<BlockNumber, Bytes>>,
|
||||
}
|
||||
|
||||
impl<'s, 'h> NetSyncIo<'s, 'h> {
|
||||
impl<'s> NetSyncIo<'s> {
|
||||
/// Creates a new instance from the `NetworkContext` and the blockchain client reference.
|
||||
pub fn new(network: &'s NetworkContext<'h>,
|
||||
pub fn new(network: &'s NetworkContext,
|
||||
chain: &'s BlockChainClient,
|
||||
snapshot_service: &'s SnapshotService,
|
||||
chain_overlay: &'s RwLock<HashMap<BlockNumber, Bytes>>) -> NetSyncIo<'s, 'h> {
|
||||
chain_overlay: &'s RwLock<HashMap<BlockNumber, Bytes>>) -> NetSyncIo<'s> {
|
||||
NetSyncIo {
|
||||
network: network,
|
||||
chain: chain,
|
||||
@@ -83,7 +83,7 @@ impl<'s, 'h> NetSyncIo<'s, 'h> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s, 'h> SyncIo for NetSyncIo<'s, 'h> {
|
||||
impl<'s> SyncIo for NetSyncIo<'s> {
|
||||
fn disable_peer(&mut self, peer_id: PeerId) {
|
||||
self.network.disable_peer(peer_id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user