Remove updater
This commit is contained in:
@@ -48,7 +48,6 @@ extern crate order_stat;
|
||||
extern crate parking_lot;
|
||||
extern crate rand;
|
||||
extern crate rustc_hex;
|
||||
extern crate semver;
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
extern crate tokio_timer;
|
||||
@@ -77,7 +76,6 @@ extern crate keccak_hash as hash;
|
||||
extern crate parity_bytes as bytes;
|
||||
extern crate parity_crypto as crypto;
|
||||
extern crate parity_runtime;
|
||||
extern crate parity_updater as updater;
|
||||
extern crate parity_version as version;
|
||||
extern crate rlp;
|
||||
extern crate stats;
|
||||
|
||||
@@ -31,7 +31,6 @@ use ethstore::random_phrase;
|
||||
use jsonrpc_core::{futures::future, BoxFuture, Result};
|
||||
use sync::{ManageNetwork, SyncProvider};
|
||||
use types::ids::BlockId;
|
||||
use updater::Service as UpdateService;
|
||||
use version::version_data;
|
||||
|
||||
use v1::{
|
||||
@@ -45,18 +44,17 @@ use v1::{
|
||||
metadata::Metadata,
|
||||
traits::Parity,
|
||||
types::{
|
||||
block_number_to_id, BlockNumber, Bytes, CallRequest, ChainStatus, ConsensusCapability,
|
||||
Histogram, LocalTransactionStatus, OperationsInfo, Peers, Receipt, RecoveredAccount,
|
||||
RichHeader, RpcSettings, Transaction, TransactionStats, VersionInfo,
|
||||
block_number_to_id, BlockNumber, Bytes, CallRequest, ChainStatus, Histogram,
|
||||
LocalTransactionStatus, Peers, Receipt, RecoveredAccount, RichHeader, RpcSettings,
|
||||
Transaction, TransactionStats,
|
||||
},
|
||||
};
|
||||
use Host;
|
||||
|
||||
/// Parity implementation.
|
||||
pub struct ParityClient<C, M, U> {
|
||||
pub struct ParityClient<C, M> {
|
||||
client: Arc<C>,
|
||||
miner: Arc<M>,
|
||||
updater: Arc<U>,
|
||||
sync: Arc<dyn SyncProvider>,
|
||||
net: Arc<dyn ManageNetwork>,
|
||||
logger: Arc<RotatingLogger>,
|
||||
@@ -66,7 +64,7 @@ pub struct ParityClient<C, M, U> {
|
||||
snapshot: Option<Arc<dyn SnapshotService>>,
|
||||
}
|
||||
|
||||
impl<C, M, U> ParityClient<C, M, U>
|
||||
impl<C, M> ParityClient<C, M>
|
||||
where
|
||||
C: BlockChainClient,
|
||||
{
|
||||
@@ -75,7 +73,6 @@ where
|
||||
client: Arc<C>,
|
||||
miner: Arc<M>,
|
||||
sync: Arc<dyn SyncProvider>,
|
||||
updater: Arc<U>,
|
||||
net: Arc<dyn ManageNetwork>,
|
||||
logger: Arc<RotatingLogger>,
|
||||
settings: Arc<NetworkSettings>,
|
||||
@@ -87,7 +84,6 @@ where
|
||||
client,
|
||||
miner,
|
||||
sync,
|
||||
updater,
|
||||
net,
|
||||
logger,
|
||||
settings,
|
||||
@@ -98,7 +94,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<C, M, U, S> Parity for ParityClient<C, M, U>
|
||||
impl<C, M, S> Parity for ParityClient<C, M>
|
||||
where
|
||||
S: StateInfo + 'static,
|
||||
C: miner::BlockChainClient
|
||||
@@ -107,7 +103,6 @@ where
|
||||
+ Call<State = S>
|
||||
+ 'static,
|
||||
M: MinerService<State = S> + 'static,
|
||||
U: UpdateService + 'static,
|
||||
{
|
||||
type Metadata = Metadata;
|
||||
|
||||
@@ -330,18 +325,6 @@ where
|
||||
self.sync.enode().ok_or_else(errors::network_disabled)
|
||||
}
|
||||
|
||||
fn consensus_capability(&self) -> Result<ConsensusCapability> {
|
||||
Ok(self.updater.capability().into())
|
||||
}
|
||||
|
||||
fn version_info(&self) -> Result<VersionInfo> {
|
||||
Ok(self.updater.version_info().into())
|
||||
}
|
||||
|
||||
fn releases_info(&self) -> Result<Option<OperationsInfo>> {
|
||||
Ok(self.updater.info().map(Into::into))
|
||||
}
|
||||
|
||||
fn chain_status(&self) -> Result<ChainStatus> {
|
||||
let chain_info = self.client.chain_info();
|
||||
|
||||
|
||||
@@ -27,13 +27,12 @@ use ethkey;
|
||||
use fetch::{self, Fetch};
|
||||
use hash::keccak_buffer;
|
||||
use sync::ManageNetwork;
|
||||
use updater::Service as UpdateService;
|
||||
|
||||
use jsonrpc_core::{futures::Future, BoxFuture, Result};
|
||||
use v1::{
|
||||
helpers::errors,
|
||||
traits::ParitySet,
|
||||
types::{Bytes, ReleaseInfo, Transaction},
|
||||
types::{Bytes, Transaction},
|
||||
};
|
||||
|
||||
#[cfg(any(test, feature = "accounts"))]
|
||||
@@ -82,41 +81,32 @@ pub mod accounts {
|
||||
}
|
||||
|
||||
/// Parity-specific rpc interface for operations altering the settings.
|
||||
pub struct ParitySetClient<C, M, U, F = fetch::Client> {
|
||||
pub struct ParitySetClient<C, M, F = fetch::Client> {
|
||||
client: Arc<C>,
|
||||
miner: Arc<M>,
|
||||
updater: Arc<U>,
|
||||
net: Arc<dyn ManageNetwork>,
|
||||
fetch: F,
|
||||
}
|
||||
|
||||
impl<C, M, U, F> ParitySetClient<C, M, U, F>
|
||||
impl<C, M, F> ParitySetClient<C, M, F>
|
||||
where
|
||||
C: BlockChainClient + 'static,
|
||||
{
|
||||
/// Creates new `ParitySetClient` with given `Fetch`.
|
||||
pub fn new(
|
||||
client: &Arc<C>,
|
||||
miner: &Arc<M>,
|
||||
updater: &Arc<U>,
|
||||
net: &Arc<dyn ManageNetwork>,
|
||||
fetch: F,
|
||||
) -> Self {
|
||||
pub fn new(client: &Arc<C>, miner: &Arc<M>, net: &Arc<dyn ManageNetwork>, fetch: F) -> Self {
|
||||
ParitySetClient {
|
||||
client: client.clone(),
|
||||
miner: miner.clone(),
|
||||
updater: updater.clone(),
|
||||
net: net.clone(),
|
||||
fetch,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<C, M, U, F> ParitySet for ParitySetClient<C, M, U, F>
|
||||
impl<C, M, F> ParitySet for ParitySetClient<C, M, F>
|
||||
where
|
||||
C: BlockChainClient + 'static,
|
||||
M: MinerService + 'static,
|
||||
U: UpdateService + 'static,
|
||||
F: Fetch + 'static,
|
||||
{
|
||||
fn set_min_gas_price(&self, gas_price: U256) -> Result<bool> {
|
||||
@@ -239,14 +229,6 @@ where
|
||||
Box::new(future)
|
||||
}
|
||||
|
||||
fn upgrade_ready(&self) -> Result<Option<ReleaseInfo>> {
|
||||
Ok(self.updater.upgrade_ready().map(Into::into))
|
||||
}
|
||||
|
||||
fn execute_upgrade(&self) -> Result<bool> {
|
||||
Ok(self.updater.execute_upgrade())
|
||||
}
|
||||
|
||||
fn remove_transaction(&self, hash: H256) -> Result<Option<Transaction>> {
|
||||
Ok(self
|
||||
.miner
|
||||
|
||||
@@ -19,11 +19,9 @@
|
||||
mod miner_service;
|
||||
mod snapshot_service;
|
||||
mod sync_provider;
|
||||
mod update_service;
|
||||
|
||||
pub use self::{
|
||||
miner_service::TestMinerService,
|
||||
snapshot_service::TestSnapshotService,
|
||||
sync_provider::{Config, TestSyncProvider},
|
||||
update_service::TestUpdater,
|
||||
};
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Ethereum.
|
||||
|
||||
// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Test implementation of fetch client.
|
||||
|
||||
use semver::Version;
|
||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||
use updater::{
|
||||
CapState, OperationsInfo, ReleaseInfo, ReleaseTrack, Service as UpdateService, VersionInfo,
|
||||
};
|
||||
|
||||
/// Test implementation of fetcher. Will always return the same file.
|
||||
#[derive(Default)]
|
||||
pub struct TestUpdater {
|
||||
updated: AtomicBool,
|
||||
current_block: AtomicUsize,
|
||||
}
|
||||
|
||||
impl TestUpdater {
|
||||
/// Update the (faked) current block.
|
||||
pub fn set_current_block(&self, n: usize) {
|
||||
self.current_block.store(n, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// Update the (faked) current block.
|
||||
pub fn set_updated(&self, v: bool) {
|
||||
self.updated.store(v, Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
impl UpdateService for TestUpdater {
|
||||
fn capability(&self) -> CapState {
|
||||
if self.updated.load(Ordering::Relaxed) {
|
||||
CapState::Capable
|
||||
} else {
|
||||
if self.current_block.load(Ordering::Relaxed) < 15100 {
|
||||
CapState::CapableUntil(15100)
|
||||
} else {
|
||||
CapState::IncapableSince(15100)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn upgrade_ready(&self) -> Option<ReleaseInfo> {
|
||||
if self.updated.load(Ordering::Relaxed) {
|
||||
None
|
||||
} else {
|
||||
self.info().map(|i| i.track)
|
||||
}
|
||||
}
|
||||
|
||||
fn execute_upgrade(&self) -> bool {
|
||||
if self.updated.load(Ordering::Relaxed) {
|
||||
false
|
||||
} else {
|
||||
self.updated.store(true, Ordering::Relaxed);
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
fn version_info(&self) -> VersionInfo {
|
||||
VersionInfo {
|
||||
track: ReleaseTrack::Beta,
|
||||
version: Version {
|
||||
major: 1,
|
||||
minor: 5,
|
||||
patch: 0,
|
||||
build: vec![],
|
||||
pre: vec![],
|
||||
},
|
||||
hash: 150.into(),
|
||||
}
|
||||
}
|
||||
|
||||
fn info(&self) -> Option<OperationsInfo> {
|
||||
Some(OperationsInfo {
|
||||
fork: 15100,
|
||||
this_fork: Some(15000),
|
||||
track: ReleaseInfo {
|
||||
version: VersionInfo {
|
||||
track: ReleaseTrack::Beta,
|
||||
version: Version {
|
||||
major: 1,
|
||||
minor: 5,
|
||||
patch: 1,
|
||||
build: vec![],
|
||||
pre: vec![],
|
||||
},
|
||||
hash: 151.into(),
|
||||
},
|
||||
is_critical: true,
|
||||
fork: 15100,
|
||||
binary: Some(1510.into()),
|
||||
},
|
||||
minor: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -28,18 +28,17 @@ use jsonrpc_core::IoHandler;
|
||||
use v1::{
|
||||
helpers::{external_signer::SignerService, NetworkSettings},
|
||||
metadata::Metadata,
|
||||
tests::helpers::{Config, TestMinerService, TestSyncProvider, TestUpdater},
|
||||
tests::helpers::{Config, TestMinerService, TestSyncProvider},
|
||||
Parity, ParityClient,
|
||||
};
|
||||
use Host;
|
||||
|
||||
pub type TestParityClient = ParityClient<TestBlockChainClient, TestMinerService, TestUpdater>;
|
||||
pub type TestParityClient = ParityClient<TestBlockChainClient, TestMinerService>;
|
||||
|
||||
pub struct Dependencies {
|
||||
pub miner: Arc<TestMinerService>,
|
||||
pub client: Arc<TestBlockChainClient>,
|
||||
pub sync: Arc<TestSyncProvider>,
|
||||
pub updater: Arc<TestUpdater>,
|
||||
pub logger: Arc<RotatingLogger>,
|
||||
pub settings: Arc<NetworkSettings>,
|
||||
pub network: Arc<dyn ManageNetwork>,
|
||||
@@ -55,7 +54,6 @@ impl Dependencies {
|
||||
network_id: 3,
|
||||
num_peers: 120,
|
||||
})),
|
||||
updater: Arc::new(TestUpdater::default()),
|
||||
logger: Arc::new(RotatingLogger::new("rpc=trace".to_owned())),
|
||||
settings: Arc::new(NetworkSettings {
|
||||
name: "mynode".to_owned(),
|
||||
@@ -76,7 +74,6 @@ impl Dependencies {
|
||||
self.client.clone(),
|
||||
self.miner.clone(),
|
||||
self.sync.clone(),
|
||||
self.updater.clone(),
|
||||
self.network.clone(),
|
||||
self.logger.clone(),
|
||||
self.settings.clone(),
|
||||
@@ -99,51 +96,6 @@ impl Dependencies {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rpc_parity_consensus_capability() {
|
||||
let deps = Dependencies::new();
|
||||
let io = deps.default_client();
|
||||
|
||||
let request =
|
||||
r#"{"jsonrpc": "2.0", "method": "parity_consensusCapability", "params": [], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"capableUntil":15100},"id":1}"#;
|
||||
assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
|
||||
|
||||
deps.updater.set_current_block(15101);
|
||||
|
||||
let request =
|
||||
r#"{"jsonrpc": "2.0", "method": "parity_consensusCapability", "params": [], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"incapableSince":15100},"id":1}"#;
|
||||
assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
|
||||
|
||||
deps.updater.set_updated(true);
|
||||
|
||||
let request =
|
||||
r#"{"jsonrpc": "2.0", "method": "parity_consensusCapability", "params": [], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":"capable","id":1}"#;
|
||||
assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rpc_parity_version_info() {
|
||||
let deps = Dependencies::new();
|
||||
let io = deps.default_client();
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_versionInfo", "params": [], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"hash":"0x0000000000000000000000000000000000000096","track":"beta","version":{"major":1,"minor":5,"patch":0}},"id":1}"#;
|
||||
assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rpc_parity_releases_info() {
|
||||
let deps = Dependencies::new();
|
||||
let io = deps.default_client();
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_releasesInfo", "params": [], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"fork":15100,"minor":null,"this_fork":15000,"track":{"binary":"0x00000000000000000000000000000000000000000000000000000000000005e6","fork":15100,"is_critical":true,"version":{"hash":"0x0000000000000000000000000000000000000097","track":"beta","version":{"major":1,"minor":5,"patch":1}}}},"id":1}"#;
|
||||
assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rpc_parity_extra_data() {
|
||||
let deps = Dependencies::new();
|
||||
|
||||
@@ -23,10 +23,7 @@ use sync::ManageNetwork;
|
||||
|
||||
use super::manage_network::TestManageNetwork;
|
||||
use jsonrpc_core::IoHandler;
|
||||
use v1::{
|
||||
tests::helpers::{TestMinerService, TestUpdater},
|
||||
ParitySet, ParitySetClient,
|
||||
};
|
||||
use v1::{tests::helpers::TestMinerService, ParitySet, ParitySetClient};
|
||||
|
||||
use fake_fetch::FakeFetch;
|
||||
|
||||
@@ -42,75 +39,30 @@ fn network_service() -> Arc<TestManageNetwork> {
|
||||
Arc::new(TestManageNetwork)
|
||||
}
|
||||
|
||||
fn updater_service() -> Arc<TestUpdater> {
|
||||
Arc::new(TestUpdater::default())
|
||||
}
|
||||
|
||||
pub type TestParitySetClient =
|
||||
ParitySetClient<TestBlockChainClient, TestMinerService, TestUpdater, FakeFetch<usize>>;
|
||||
ParitySetClient<TestBlockChainClient, TestMinerService, FakeFetch<usize>>;
|
||||
|
||||
fn parity_set_client(
|
||||
client: &Arc<TestBlockChainClient>,
|
||||
miner: &Arc<TestMinerService>,
|
||||
updater: &Arc<TestUpdater>,
|
||||
net: &Arc<TestManageNetwork>,
|
||||
) -> TestParitySetClient {
|
||||
ParitySetClient::new(
|
||||
client,
|
||||
miner,
|
||||
updater,
|
||||
&(net.clone() as Arc<dyn ManageNetwork>),
|
||||
FakeFetch::new(Some(1)),
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rpc_parity_execute_upgrade() {
|
||||
let miner = miner_service();
|
||||
let client = client_service();
|
||||
let network = network_service();
|
||||
let updater = updater_service();
|
||||
let mut io = IoHandler::new();
|
||||
io.extend_with(parity_set_client(&client, &miner, &updater, &network).to_delegate());
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_executeUpgrade", "params": [], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
|
||||
assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_executeUpgrade", "params": [], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":false,"id":1}"#;
|
||||
assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rpc_parity_upgrade_ready() {
|
||||
let miner = miner_service();
|
||||
let client = client_service();
|
||||
let network = network_service();
|
||||
let updater = updater_service();
|
||||
let mut io = IoHandler::new();
|
||||
io.extend_with(parity_set_client(&client, &miner, &updater, &network).to_delegate());
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_upgradeReady", "params": [], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"binary":"0x00000000000000000000000000000000000000000000000000000000000005e6","fork":15100,"is_critical":true,"version":{"hash":"0x0000000000000000000000000000000000000097","track":"beta","version":{"major":1,"minor":5,"patch":1}}},"id":1}"#;
|
||||
assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
|
||||
|
||||
updater.set_updated(true);
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_upgradeReady", "params": [], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":null,"id":1}"#;
|
||||
assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rpc_parity_set_min_gas_price() {
|
||||
let miner = miner_service();
|
||||
let client = client_service();
|
||||
let network = network_service();
|
||||
let updater = updater_service();
|
||||
|
||||
let mut io = IoHandler::new();
|
||||
io.extend_with(parity_set_client(&client, &miner, &updater, &network).to_delegate());
|
||||
io.extend_with(parity_set_client(&client, &miner, &network).to_delegate());
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_setMinGasPrice", "params":["0xcd1722f3947def4cf144679da39c4c32bdc35681"], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
|
||||
@@ -125,10 +77,9 @@ fn rpc_parity_set_min_gas_price_with_automated_calibration_enabled() {
|
||||
|
||||
let client = client_service();
|
||||
let network = network_service();
|
||||
let updater = updater_service();
|
||||
|
||||
let mut io = IoHandler::new();
|
||||
io.extend_with(parity_set_client(&client, &miner, &updater, &network).to_delegate());
|
||||
io.extend_with(parity_set_client(&client, &miner, &network).to_delegate());
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_setMinGasPrice", "params":["0xdeadbeef"], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","error":{"code":-32000,"message":"Can't update fixed gas price while automatic gas calibration is enabled."},"id":1}"#;
|
||||
@@ -141,10 +92,9 @@ fn rpc_parity_set_gas_floor_target() {
|
||||
let miner = miner_service();
|
||||
let client = client_service();
|
||||
let network = network_service();
|
||||
let updater = updater_service();
|
||||
|
||||
let mut io = IoHandler::new();
|
||||
io.extend_with(parity_set_client(&client, &miner, &updater, &network).to_delegate());
|
||||
io.extend_with(parity_set_client(&client, &miner, &network).to_delegate());
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_setGasFloorTarget", "params":["0xcd1722f3947def4cf144679da39c4c32bdc35681"], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
|
||||
@@ -161,10 +111,9 @@ fn rpc_parity_set_extra_data() {
|
||||
let miner = miner_service();
|
||||
let client = client_service();
|
||||
let network = network_service();
|
||||
let updater = updater_service();
|
||||
|
||||
let mut io = IoHandler::new();
|
||||
io.extend_with(parity_set_client(&client, &miner, &updater, &network).to_delegate());
|
||||
io.extend_with(parity_set_client(&client, &miner, &network).to_delegate());
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_setExtraData", "params":["0xcd1722f3947def4cf144679da39c4c32bdc35681"], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
|
||||
@@ -183,9 +132,9 @@ fn rpc_parity_set_author() {
|
||||
let miner = miner_service();
|
||||
let client = client_service();
|
||||
let network = network_service();
|
||||
let updater = updater_service();
|
||||
|
||||
let mut io = IoHandler::new();
|
||||
io.extend_with(parity_set_client(&client, &miner, &updater, &network).to_delegate());
|
||||
io.extend_with(parity_set_client(&client, &miner, &network).to_delegate());
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_setAuthor", "params":["0xcd1722f3947def4cf144679da39c4c32bdc35681"], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
|
||||
@@ -202,9 +151,9 @@ fn rpc_parity_set_transactions_limit() {
|
||||
let miner = miner_service();
|
||||
let client = client_service();
|
||||
let network = network_service();
|
||||
let updater = updater_service();
|
||||
|
||||
let mut io = IoHandler::new();
|
||||
io.extend_with(parity_set_client(&client, &miner, &updater, &network).to_delegate());
|
||||
io.extend_with(parity_set_client(&client, &miner, &network).to_delegate());
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_setTransactionsLimit", "params":[10240240], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":false,"id":1}"#;
|
||||
@@ -217,9 +166,9 @@ fn rpc_parity_set_hash_content() {
|
||||
let miner = miner_service();
|
||||
let client = client_service();
|
||||
let network = network_service();
|
||||
let updater = updater_service();
|
||||
|
||||
let mut io = IoHandler::new();
|
||||
io.extend_with(parity_set_client(&client, &miner, &updater, &network).to_delegate());
|
||||
io.extend_with(parity_set_client(&client, &miner, &network).to_delegate());
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_hashContent", "params":["https://parity.io/assets/images/ethcore-black-horizontal.png"], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":"0x2be00befcf008bc0e7d9cdefc194db9c75352e8632f48498b5a6bfce9f02c88e","id":1}"#;
|
||||
@@ -234,9 +183,9 @@ fn rpc_parity_remove_transaction() {
|
||||
let miner = miner_service();
|
||||
let client = client_service();
|
||||
let network = network_service();
|
||||
let updater = updater_service();
|
||||
|
||||
let mut io = IoHandler::new();
|
||||
io.extend_with(parity_set_client(&client, &miner, &updater, &network).to_delegate());
|
||||
io.extend_with(parity_set_client(&client, &miner, &network).to_delegate());
|
||||
|
||||
let tx = Transaction {
|
||||
nonce: 1.into(),
|
||||
|
||||
@@ -22,9 +22,8 @@ use ethereum_types::{H160, H256, H512, H64, U256, U64};
|
||||
use jsonrpc_core::{BoxFuture, Result};
|
||||
use jsonrpc_derive::rpc;
|
||||
use v1::types::{
|
||||
BlockNumber, Bytes, CallRequest, ChainStatus, ConsensusCapability, Histogram,
|
||||
LocalTransactionStatus, OperationsInfo, Peers, Receipt, RecoveredAccount, RichHeader,
|
||||
RpcSettings, Transaction, TransactionStats, VersionInfo,
|
||||
BlockNumber, Bytes, CallRequest, ChainStatus, Histogram, LocalTransactionStatus, Peers,
|
||||
Receipt, RecoveredAccount, RichHeader, RpcSettings, Transaction, TransactionStats,
|
||||
};
|
||||
|
||||
/// Parity-specific rpc interface.
|
||||
@@ -177,18 +176,6 @@ pub trait Parity {
|
||||
#[rpc(name = "parity_enode")]
|
||||
fn enode(&self) -> Result<String>;
|
||||
|
||||
/// Returns information on current consensus capability.
|
||||
#[rpc(name = "parity_consensusCapability")]
|
||||
fn consensus_capability(&self) -> Result<ConsensusCapability>;
|
||||
|
||||
/// Get our version information in a nice object.
|
||||
#[rpc(name = "parity_versionInfo")]
|
||||
fn version_info(&self) -> Result<VersionInfo>;
|
||||
|
||||
/// Get information concerning the latest releases if available.
|
||||
#[rpc(name = "parity_releasesInfo")]
|
||||
fn releases_info(&self) -> Result<Option<OperationsInfo>>;
|
||||
|
||||
/// Get the current chain status.
|
||||
#[rpc(name = "parity_chainStatus")]
|
||||
fn chain_status(&self) -> Result<ChainStatus>;
|
||||
|
||||
@@ -20,7 +20,7 @@ use ethereum_types::{H160, H256, U256};
|
||||
use jsonrpc_core::{BoxFuture, Result};
|
||||
use jsonrpc_derive::rpc;
|
||||
|
||||
use v1::types::{Bytes, ReleaseInfo, Transaction};
|
||||
use v1::types::{Bytes, Transaction};
|
||||
|
||||
/// Parity-specific rpc interface for operations altering the account-related settings.
|
||||
#[rpc(server)]
|
||||
@@ -105,14 +105,6 @@ pub trait ParitySet {
|
||||
#[rpc(name = "parity_hashContent")]
|
||||
fn hash_content(&self, _: String) -> BoxFuture<H256>;
|
||||
|
||||
/// Is there a release ready for install?
|
||||
#[rpc(name = "parity_upgradeReady")]
|
||||
fn upgrade_ready(&self) -> Result<Option<ReleaseInfo>>;
|
||||
|
||||
/// Execute a release which is ready according to upgrade_ready().
|
||||
#[rpc(name = "parity_executeUpgrade")]
|
||||
fn execute_upgrade(&self) -> Result<bool>;
|
||||
|
||||
/// Removes transaction from transaction queue.
|
||||
/// Makes sense only for transactions that were not propagated to other peers yet
|
||||
/// like scheduled transactions or transactions in future.
|
||||
|
||||
@@ -1,163 +0,0 @@
|
||||
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Ethereum.
|
||||
|
||||
// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use ethereum_types::{H160, H256};
|
||||
use semver;
|
||||
use updater::{self, CapState};
|
||||
|
||||
/// Capability info
|
||||
#[derive(Debug, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum ConsensusCapability {
|
||||
/// Unknown.
|
||||
Unknown,
|
||||
/// Capable of consensus indefinitely.
|
||||
Capable,
|
||||
/// Capable of consensus up until a definite block.
|
||||
CapableUntil(u64),
|
||||
/// Incapable of consensus since a particular block.
|
||||
IncapableSince(u64),
|
||||
}
|
||||
|
||||
impl Into<ConsensusCapability> for CapState {
|
||||
fn into(self) -> ConsensusCapability {
|
||||
match self {
|
||||
CapState::Unknown => ConsensusCapability::Unknown,
|
||||
CapState::Capable => ConsensusCapability::Capable,
|
||||
CapState::CapableUntil(n) => ConsensusCapability::CapableUntil(n),
|
||||
CapState::IncapableSince(n) => ConsensusCapability::IncapableSince(n),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A release's track.
|
||||
#[derive(Debug, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum ReleaseTrack {
|
||||
/// Stable track.
|
||||
Stable,
|
||||
/// Beta track.
|
||||
Beta,
|
||||
/// Nightly track.
|
||||
Nightly,
|
||||
/// Testing track.
|
||||
Testing,
|
||||
/// No known track.
|
||||
#[serde(rename = "null")]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
impl Into<ReleaseTrack> for updater::ReleaseTrack {
|
||||
fn into(self) -> ReleaseTrack {
|
||||
match self {
|
||||
updater::ReleaseTrack::Stable => ReleaseTrack::Stable,
|
||||
updater::ReleaseTrack::Beta => ReleaseTrack::Beta,
|
||||
updater::ReleaseTrack::Nightly => ReleaseTrack::Nightly,
|
||||
updater::ReleaseTrack::Testing => ReleaseTrack::Testing,
|
||||
updater::ReleaseTrack::Unknown => ReleaseTrack::Unknown,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Semantic version.
|
||||
#[derive(Debug, PartialEq, Serialize)]
|
||||
pub struct Version {
|
||||
/// Major part.
|
||||
major: u64,
|
||||
/// Minor part.
|
||||
minor: u64,
|
||||
/// Patch part.
|
||||
patch: u64,
|
||||
}
|
||||
|
||||
impl Into<Version> for semver::Version {
|
||||
fn into(self) -> Version {
|
||||
Version {
|
||||
major: self.major,
|
||||
minor: self.minor,
|
||||
patch: self.patch,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Version information of a particular release.
|
||||
#[derive(Debug, PartialEq, Serialize)]
|
||||
pub struct VersionInfo {
|
||||
/// The track on which it was released.
|
||||
pub track: ReleaseTrack,
|
||||
/// The version.
|
||||
pub version: Version,
|
||||
/// The (SHA1?) 160-bit hash of this build's code base.
|
||||
pub hash: H160,
|
||||
}
|
||||
|
||||
impl Into<VersionInfo> for updater::VersionInfo {
|
||||
fn into(self) -> VersionInfo {
|
||||
VersionInfo {
|
||||
track: self.track.into(),
|
||||
version: self.version.into(),
|
||||
hash: self.hash,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Information regarding a particular release of Parity
|
||||
#[derive(Debug, PartialEq, Serialize)]
|
||||
pub struct ReleaseInfo {
|
||||
/// Information on the version.
|
||||
pub version: VersionInfo,
|
||||
/// Does this release contain critical security updates?
|
||||
pub is_critical: bool,
|
||||
/// The latest fork that this release can handle.
|
||||
pub fork: u64,
|
||||
/// Our platform's binary, if known.
|
||||
pub binary: Option<H256>,
|
||||
}
|
||||
|
||||
impl Into<ReleaseInfo> for updater::ReleaseInfo {
|
||||
fn into(self) -> ReleaseInfo {
|
||||
ReleaseInfo {
|
||||
version: self.version.into(),
|
||||
is_critical: self.is_critical,
|
||||
fork: self.fork,
|
||||
binary: self.binary.map(Into::into),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Information on our operations environment.
|
||||
#[derive(Debug, PartialEq, Serialize)]
|
||||
pub struct OperationsInfo {
|
||||
/// Our blockchain's latest fork.
|
||||
pub fork: u64,
|
||||
/// Last fork our client supports, if known.
|
||||
pub this_fork: Option<u64>,
|
||||
/// Information on our track's latest release.
|
||||
pub track: ReleaseInfo,
|
||||
/// Information on our minor version's latest release.
|
||||
pub minor: Option<ReleaseInfo>,
|
||||
}
|
||||
|
||||
impl Into<OperationsInfo> for updater::OperationsInfo {
|
||||
fn into(self) -> OperationsInfo {
|
||||
OperationsInfo {
|
||||
fork: self.fork,
|
||||
this_fork: self.this_fork,
|
||||
track: self.track.into(),
|
||||
minor: self.minor.map(Into::into),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@ mod block_number;
|
||||
mod bytes;
|
||||
mod call_request;
|
||||
mod confirmations;
|
||||
mod consensus_status;
|
||||
mod derivation;
|
||||
mod eip191;
|
||||
mod filter;
|
||||
@@ -59,7 +58,6 @@ pub use self::{
|
||||
ConfirmationResponseWithToken, DecryptRequest, EIP191SignRequest, Either, EthSignRequest,
|
||||
TransactionModification,
|
||||
},
|
||||
consensus_status::*,
|
||||
derivation::{Derive, DeriveHash, DeriveHierarchical},
|
||||
eip191::{EIP191Version, PresignedTransaction},
|
||||
filter::{Filter, FilterChanges},
|
||||
|
||||
Reference in New Issue
Block a user