Dapps port RPC (#2819)

This commit is contained in:
Tomasz Drwięga
2016-10-24 12:21:15 +02:00
committed by Gav Wood
parent 8cf9934cab
commit e5f86c62ad
13 changed files with 223 additions and 223 deletions

View File

@@ -52,7 +52,8 @@ pub struct EthcoreClient<C, M, S: ?Sized, F=FetchClient> where
logger: Arc<RotatingLogger>,
settings: Arc<NetworkSettings>,
signer: Option<Arc<SignerService>>,
fetch: Mutex<F>
fetch: Mutex<F>,
dapps_port: Option<u16>,
}
impl<C, M, S: ?Sized> EthcoreClient<C, M, S> where
@@ -67,9 +68,10 @@ impl<C, M, S: ?Sized> EthcoreClient<C, M, S> where
net: &Arc<ManageNetwork>,
logger: Arc<RotatingLogger>,
settings: Arc<NetworkSettings>,
signer: Option<Arc<SignerService>>
signer: Option<Arc<SignerService>>,
dapps_port: Option<u16>,
) -> Self {
Self::with_fetch(client, miner, sync, net, logger, settings, signer)
Self::with_fetch(client, miner, sync, net, logger, settings, signer, dapps_port)
}
}
@@ -87,7 +89,8 @@ impl<C, M, S: ?Sized, F> EthcoreClient<C, M, S, F> where
net: &Arc<ManageNetwork>,
logger: Arc<RotatingLogger>,
settings: Arc<NetworkSettings>,
signer: Option<Arc<SignerService>>
signer: Option<Arc<SignerService>>,
dapps_port: Option<u16>,
) -> Self {
EthcoreClient {
client: Arc::downgrade(client),
@@ -98,6 +101,7 @@ impl<C, M, S: ?Sized, F> EthcoreClient<C, M, S, F> where
settings: settings,
signer: signer,
fetch: Mutex::new(F::default()),
dapps_port: dapps_port,
}
}
@@ -314,4 +318,20 @@ impl<C, M, S: ?Sized, F> Ethcore for EthcoreClient<C, M, S, F> where
}
}
}
fn signer_port(&self) -> Result<u16, Error> {
try!(self.active());
self.signer
.clone()
.and_then(|signer| signer.port())
.ok_or_else(|| errors::signer_disabled())
}
fn dapps_port(&self) -> Result<u16, Error> {
try!(self.active());
self.dapps_port
.ok_or_else(|| errors::dapps_disabled())
}
}

View File

@@ -34,18 +34,16 @@ pub struct PersonalClient<C, M> where C: MiningBlockChainClient, M: MinerService
accounts: Weak<AccountProvider>,
client: Weak<C>,
miner: Weak<M>,
signer_port: Option<u16>,
allow_perm_unlock: bool,
}
impl<C, M> PersonalClient<C, M> where C: MiningBlockChainClient, M: MinerService {
/// Creates new PersonalClient
pub fn new(store: &Arc<AccountProvider>, client: &Arc<C>, miner: &Arc<M>, signer_port: Option<u16>, allow_perm_unlock: bool) -> Self {
pub fn new(store: &Arc<AccountProvider>, client: &Arc<C>, miner: &Arc<M>, allow_perm_unlock: bool) -> Self {
PersonalClient {
accounts: Arc::downgrade(store),
client: Arc::downgrade(client),
miner: Arc::downgrade(miner),
signer_port: signer_port,
allow_perm_unlock: allow_perm_unlock,
}
}
@@ -59,15 +57,6 @@ impl<C, M> PersonalClient<C, M> where C: MiningBlockChainClient, M: MinerService
impl<C: 'static, M: 'static> Personal for PersonalClient<C, M> where C: MiningBlockChainClient, M: MinerService {
fn signer_enabled(&self, params: Params) -> Result<Value, Error> {
try!(self.active());
try!(expect_no_params(params));
Ok(self.signer_port
.map(|v| to_value(&v))
.unwrap_or_else(|| to_value(&false)))
}
fn accounts(&self, params: Params) -> Result<Value, Error> {
try!(self.active());
try!(expect_no_params(params));