This repository was archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Sync stand-alone binary and feature-gated dependencies refactoring #1637
Merged
Changes from 12 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
2310ecb
sorting out the multi-interface dispatch scenario
NikVolf f380340
codegen expansion for traits
NikVolf c60e02d
fix rwlock
NikVolf 507a4ea
basic layout of sync executable and minor fixes in the api
NikVolf 4a9d57d
flush work
NikVolf b1a67bf
hypervisor refactoring
NikVolf 98ddff1
dependancies layout
NikVolf 4cb1c90
rpc dependencies relayout
NikVolf fea05dc
toml file fix
NikVolf be25e93
Merge branch 'master' into sync-svc
NikVolf ac8db8f
redundant crate
NikVolf a74b72f
submodules update
NikVolf 8e26977
review fixes
NikVolf 77bbab0
got rid of Arc<T> dispatch
NikVolf c3ef5c1
got rid of the generic parameter for ipc interface
NikVolf 9eed51e
comments -
NikVolf a44e95b
hashing secret on the sync side
NikVolf 6a47fd1
remove import glob
NikVolf 028d6f6
Merge branch 'master' into sync-svc
NikVolf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,7 @@ mod migration; | |
mod signer; | ||
mod rpc_apis; | ||
mod url; | ||
mod modules; | ||
|
||
use std::io::{Write, Read, BufReader, BufRead}; | ||
use std::ops::Deref; | ||
|
@@ -85,12 +86,11 @@ use rustc_serialize::hex::FromHex; | |
use ctrlc::CtrlC; | ||
use util::{H256, ToPretty, PayloadInfo, Bytes, Colour, version, journaldb}; | ||
use util::panics::{MayPanic, ForwardPanic, PanicHandler}; | ||
use ethcore::client::{BlockID, BlockChainClient, ClientConfig, get_db_path, BlockImportError, | ||
ChainNotify, Mode}; | ||
use ethcore::client::{BlockID, BlockChainClient, ClientConfig, get_db_path, BlockImportError, Mode}; | ||
use ethcore::error::{ImportError}; | ||
use ethcore::service::ClientService; | ||
use ethcore::spec::Spec; | ||
use ethsync::{EthSync, NetworkConfiguration}; | ||
use ethsync::{NetworkConfiguration}; | ||
use ethcore::miner::{Miner, MinerService, ExternalMiner}; | ||
use migration::migrate; | ||
use informant::Informant; | ||
|
@@ -244,27 +244,32 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig) | |
let network_settings = Arc::new(conf.network_settings()); | ||
|
||
// Sync | ||
let sync = EthSync::new(sync_config, client.clone(), NetworkConfiguration::from(net_settings)) | ||
.unwrap_or_else(|e| die_with_error("Sync", ethcore::error::Error::Util(e))); | ||
service.set_notify(&(sync.clone() as Arc<ChainNotify>)); | ||
let (sync_provider, manage_network, chain_notify) = | ||
modules::sync(sync_config, NetworkConfiguration::from(net_settings), client.clone()) | ||
.unwrap_or_else(|e| die_with_error("Sync", e)); | ||
// | ||
// let sync = EthSync::new(sync_config, client.clone(), NetworkConfiguration::from(net_settings)) | ||
// .unwrap_or_else(|e| die_with_error("Sync", ethcore::error::Error::Util(e))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. commented out code |
||
service.set_notify(&chain_notify); | ||
|
||
// if network is active by default | ||
if match conf.mode() { Mode::Dark(..) => false, _ => !conf.args.flag_no_network } { | ||
sync.start(); | ||
chain_notify.start(); | ||
} | ||
|
||
let deps_for_rpc_apis = Arc::new(rpc_apis::Dependencies { | ||
signer_port: conf.signer_port(), | ||
signer_queue: Arc::new(rpc_apis::ConfirmationsQueue::default()), | ||
client: client.clone(), | ||
sync: sync.clone(), | ||
sync: sync_provider.clone(), | ||
net: manage_network.clone(), | ||
secret_store: account_service.clone(), | ||
miner: miner.clone(), | ||
external_miner: external_miner.clone(), | ||
logger: logger.clone(), | ||
settings: network_settings.clone(), | ||
allow_pending_receipt_query: !conf.args.flag_geth, | ||
net_service: sync.clone(), | ||
net_service: manage_network.clone(), | ||
}); | ||
|
||
let dependencies = rpc::Dependencies { | ||
|
@@ -312,7 +317,8 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig) | |
let io_handler = Arc::new(ClientIoHandler { | ||
client: service.client(), | ||
info: Informant::new(conf.have_color()), | ||
sync: sync.clone(), | ||
sync: sync_provider.clone(), | ||
net: manage_network.clone(), | ||
accounts: account_service.clone(), | ||
}); | ||
service.register_io_handler(io_handler).expect("Error registering IO handler"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2015, 2016 Ethcore (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
use ethsync::{EthSync, SyncProvider, ManageNetwork, SyncConfig, NetworkConfiguration}; | ||
use std::sync::Arc; | ||
use ethcore::client::{ChainNotify, BlockChainClient}; | ||
use ethcore; | ||
|
||
#[cfg(feature="ipc")] | ||
pub fn sync( | ||
sync_cfg: SyncConfig, | ||
net_cfg: NetworkConfiguration, | ||
client: Arc<BlockChainClient>) | ||
-> Result<(Arc<SyncProvider>, Arc<ManageNetwork>, Arc<ChainNotify>), ethcore::error::Error> | ||
{ | ||
} | ||
|
||
#[cfg(not(feature="ipc"))] | ||
pub fn sync( | ||
sync_cfg: SyncConfig, | ||
net_cfg: NetworkConfiguration, | ||
client: Arc<BlockChainClient>) | ||
-> Result<(Arc<SyncProvider>, Arc<ManageNetwork>, Arc<ChainNotify>), ethcore::error::Error> | ||
{ | ||
let eth_sync = try!(EthSync::new(sync_cfg, client, net_cfg).map_err(|e| ethcore::error::Error::Util(e))); | ||
Ok((eth_sync.clone() as Arc<SyncProvider>, eth_sync.clone() as Arc<ManageNetwork>, eth_sync.clone() as Arc<ChainNotify>)) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am becoming wary of anything that uses
&Arc<T>
since it makes it too easy to perform unnecessary atomic operations. this kind ofderef
impl will also hurt readability because basically the only thing you can do with a&Arc<T>
over a&T
is callclone
. But then it will look like you've cloned theGuardedSocket
...and gotten back anArc<S>
?why not have an explicit
clone_client
method?edit: we do! it's called
service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rphmeier because actual dispatch is implemented for Arc of T, but not for T
see here:
https://github.com/ethcore/parity/blob/master/ipc/codegen/src/codegen.rs#L838
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the implementation do further cloning of
self
and sharing it between threads? if it doesn't then the impl should just be forT
. that is strictly more flexible.even so, that doesn't require this
deref
implThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because $interface_endpoint can be trait
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and the same time, say, EthSync can host multiple endpoints and you end up with confilcting implementations of IpcInterface for EthSync
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can implement the trait for the unsized trait object type as shown here: https://is.gd/1YaeHw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably won't work when all this interfaces are in different crates
but don't know how to check that