fixed sync with client only
This commit is contained in:
@@ -11,7 +11,6 @@ authors = ["Ethcore <admin@ethcore.io"]
|
||||
ethcore-util = { path = "../util" }
|
||||
ethcore = { path = "../ethcore" }
|
||||
clippy = { version = "0.0.69", optional = true}
|
||||
ethminer = { path = "../miner" }
|
||||
log = "0.3"
|
||||
env_logger = "0.3"
|
||||
time = "0.1.34"
|
||||
@@ -20,4 +19,4 @@ heapsize = "0.3"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethminer/dev"]
|
||||
dev = ["clippy", "ethcore/dev", "ethcore-util/dev"]
|
||||
|
||||
@@ -97,11 +97,11 @@ use ethcore::client::{BlockChainClient, BlockStatus, BlockID, BlockChainInfo};
|
||||
use ethcore::error::*;
|
||||
use ethcore::transaction::SignedTransaction;
|
||||
use ethcore::block::Block;
|
||||
use ethminer::{Miner, MinerService, AccountDetails};
|
||||
use io::SyncIo;
|
||||
use time;
|
||||
use super::SyncConfig;
|
||||
use blocks::BlockCollection;
|
||||
use ethcore::miner::{AccountDetails, TransactionImportResult};
|
||||
|
||||
known_heap_size!(0, PeerInfo);
|
||||
|
||||
@@ -241,15 +241,13 @@ pub struct ChainSync {
|
||||
imported_this_round: Option<usize>,
|
||||
/// Network ID
|
||||
network_id: U256,
|
||||
/// Miner
|
||||
miner: Arc<Miner>,
|
||||
}
|
||||
|
||||
type RlpResponseResult = Result<Option<(PacketId, RlpStream)>, PacketDecodeError>;
|
||||
|
||||
impl ChainSync {
|
||||
/// Create a new instance of syncing strategy.
|
||||
pub fn new(config: SyncConfig, miner: Arc<Miner>, chain: &BlockChainClient) -> ChainSync {
|
||||
pub fn new(config: SyncConfig, chain: &BlockChainClient) -> ChainSync {
|
||||
let chain = chain.chain_info();
|
||||
let mut sync = ChainSync {
|
||||
state: SyncState::ChainHead,
|
||||
@@ -265,7 +263,6 @@ impl ChainSync {
|
||||
imported_this_round: None,
|
||||
_max_download_ahead_blocks: max(MAX_HEADERS_TO_REQUEST, config.max_download_ahead_blocks),
|
||||
network_id: config.network_id,
|
||||
miner: miner,
|
||||
};
|
||||
sync.reset();
|
||||
sync
|
||||
@@ -903,7 +900,7 @@ impl ChainSync {
|
||||
nonce: chain.latest_nonce(a),
|
||||
balance: chain.latest_balance(a),
|
||||
};
|
||||
let _ = io.chain().import_transactions(transactions, fetch_account);
|
||||
let _ = io.chain().import_transactions(transactions);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1288,7 +1285,6 @@ mod tests {
|
||||
use ethcore::header::*;
|
||||
use ethcore::client::*;
|
||||
use ethcore::spec::Spec;
|
||||
use ethminer::{Miner, MinerService};
|
||||
|
||||
fn get_dummy_block(order: u32, parent_hash: H256) -> Bytes {
|
||||
let mut header = Header::new();
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use ethcore::client::MiningClient;
|
||||
use util::{NetworkContext, PeerId, PacketId,};
|
||||
use util::error::UtilError;
|
||||
use ethcore::service::SyncMessage;
|
||||
use ethcore::client::BlockChainClient;
|
||||
|
||||
/// IO interface for the syning handler.
|
||||
/// Provides peer connection management and an interface to the blockchain client.
|
||||
@@ -32,7 +32,7 @@ pub trait SyncIo {
|
||||
/// Send a packet to a peer.
|
||||
fn send(&mut self, peer_id: PeerId, packet_id: PacketId, data: Vec<u8>) -> Result<(), UtilError>;
|
||||
/// Get the blockchain
|
||||
fn chain(&self) -> &MiningClient;
|
||||
fn chain(&self) -> &BlockChainClient;
|
||||
/// Returns peer client identifier string
|
||||
fn peer_info(&self, peer_id: PeerId) -> String {
|
||||
peer_id.to_string()
|
||||
@@ -46,12 +46,12 @@ pub trait SyncIo {
|
||||
/// Wraps `NetworkContext` and the blockchain client
|
||||
pub struct NetSyncIo<'s, 'h> where 'h: 's {
|
||||
network: &'s NetworkContext<'h, SyncMessage>,
|
||||
chain: &'s MiningClient
|
||||
chain: &'s BlockChainClient
|
||||
}
|
||||
|
||||
impl<'s, 'h> NetSyncIo<'s, 'h> {
|
||||
/// Creates a new instance from the `NetworkContext` and the blockchain client reference.
|
||||
pub fn new(network: &'s NetworkContext<'h, SyncMessage>, chain: &'s MiningClient) -> NetSyncIo<'s, 'h> {
|
||||
pub fn new(network: &'s NetworkContext<'h, SyncMessage>, chain: &'s BlockChainClient) -> NetSyncIo<'s, 'h> {
|
||||
NetSyncIo {
|
||||
network: network,
|
||||
chain: chain,
|
||||
|
||||
@@ -55,7 +55,6 @@ extern crate log;
|
||||
#[macro_use]
|
||||
extern crate ethcore_util as util;
|
||||
extern crate ethcore;
|
||||
extern crate ethminer;
|
||||
extern crate env_logger;
|
||||
extern crate time;
|
||||
extern crate rand;
|
||||
@@ -69,7 +68,6 @@ use util::TimerToken;
|
||||
use util::{U256, ONE_U256};
|
||||
use ethcore::client::Client;
|
||||
use ethcore::service::SyncMessage;
|
||||
use ethminer::Miner;
|
||||
use io::NetSyncIo;
|
||||
use chain::ChainSync;
|
||||
|
||||
@@ -115,8 +113,8 @@ pub use self::chain::{SyncStatus, SyncState};
|
||||
|
||||
impl EthSync {
|
||||
/// Creates and register protocol with the network service
|
||||
pub fn register(service: &mut NetworkService<SyncMessage>, config: SyncConfig, chain: Arc<Client>, miner: Arc<Miner>) -> Arc<EthSync> {
|
||||
let sync = ChainSync::new(config, miner, chain.deref());
|
||||
pub fn register(service: &mut NetworkService<SyncMessage>, config: SyncConfig, chain: Arc<Client>) -> Arc<EthSync> {
|
||||
let sync = ChainSync::new(config, chain.deref());
|
||||
let sync = Arc::new(EthSync {
|
||||
chain: chain,
|
||||
sync: RwLock::new(sync),
|
||||
|
||||
@@ -19,7 +19,6 @@ use ethcore::client::{TestBlockChainClient, BlockChainClient};
|
||||
use ethcore::spec::Spec;
|
||||
use io::SyncIo;
|
||||
use chain::ChainSync;
|
||||
use ethminer::Miner;
|
||||
use ::SyncConfig;
|
||||
|
||||
pub struct TestIo<'p> {
|
||||
|
||||
Reference in New Issue
Block a user