Add first Updater RPC.
This commit is contained in:
		
							parent
							
								
									d81d9d77b2
								
							
						
					
					
						commit
						2d0d4682ad
					
				| @ -38,7 +38,7 @@ use v1::types::{ | |||||||
| 	Bytes, U256, H160, H256, H512, | 	Bytes, U256, H160, H256, H512, | ||||||
| 	Peers, Transaction, RpcSettings, Histogram, | 	Peers, Transaction, RpcSettings, Histogram, | ||||||
| 	TransactionStats, LocalTransactionStatus, | 	TransactionStats, LocalTransactionStatus, | ||||||
| 	BlockNumber, | 	BlockNumber, ConsensusCapability | ||||||
| }; | }; | ||||||
| use v1::helpers::{errors, SigningQueue, SignerService, NetworkSettings}; | use v1::helpers::{errors, SigningQueue, SignerService, NetworkSettings}; | ||||||
| use v1::helpers::dispatch::DEFAULT_MAC; | use v1::helpers::dispatch::DEFAULT_MAC; | ||||||
| @ -360,4 +360,10 @@ impl<C, M, S: ?Sized, U> Parity for ParityClient<C, M, S, U> where | |||||||
| 			(format!("0x{}", a.hex()), m) | 			(format!("0x{}", a.hex()), m) | ||||||
| 		}).collect()) | 		}).collect()) | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	fn consensus_capability(&self) -> Result<ConsensusCapability, Error> { | ||||||
|  | 		try!(self.active()); | ||||||
|  | 		let updater = take_weak!(self.updater); | ||||||
|  | 		Ok(updater.capability().into()) | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ use v1::types::{ | |||||||
| 	H160, H256, H512, U256, Bytes, | 	H160, H256, H512, U256, Bytes, | ||||||
| 	Peers, Transaction, RpcSettings, Histogram, | 	Peers, Transaction, RpcSettings, Histogram, | ||||||
| 	TransactionStats, LocalTransactionStatus, | 	TransactionStats, LocalTransactionStatus, | ||||||
| 	BlockNumber | 	BlockNumber, ConsensusCapability | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| build_rpc_trait! { | build_rpc_trait! { | ||||||
| @ -155,5 +155,9 @@ build_rpc_trait! { | |||||||
| 		/// Returns accounts information.
 | 		/// Returns accounts information.
 | ||||||
| 		#[rpc(name = "parity_accounts")] | 		#[rpc(name = "parity_accounts")] | ||||||
| 		fn accounts(&self) -> Result<BTreeMap<String, BTreeMap<String, String>>, Error>; | 		fn accounts(&self) -> Result<BTreeMap<String, BTreeMap<String, String>>, Error>; | ||||||
|  | 
 | ||||||
|  | 		/// Returns information on current consensus capability.
 | ||||||
|  | 		#[rpc(name = "parity_consensusCapability")] | ||||||
|  | 		fn consensus_capability(&self) -> Result<ConsensusCapability, Error>; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										46
									
								
								rpc/src/v1/types/consensus_status.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								rpc/src/v1/types/consensus_status.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,46 @@ | |||||||
|  | // Copyright 2015, 2016 Parity Technologies (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 updater::CapState; | ||||||
|  | 
 | ||||||
|  | /// Capability info
 | ||||||
|  | #[derive(Debug, Serialize, PartialEq)] | ||||||
|  | pub enum ConsensusCapability { | ||||||
|  | 	/// Unknown.
 | ||||||
|  | 	#[serde(rename="unknown")] | ||||||
|  | 	Unknown, | ||||||
|  | 	/// Capable of consensus indefinitely.
 | ||||||
|  | 	#[serde(rename="capable")] | ||||||
|  | 	Capable, | ||||||
|  | 	/// Capable of consensus up until a definite block. 
 | ||||||
|  | 	#[serde(rename="capableUntil")] | ||||||
|  | 	CapableUntil(u64), | ||||||
|  | 	/// Incapable of consensus since a particular block. 
 | ||||||
|  | 	#[serde(rename="incapableSince")] | ||||||
|  | 	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), 
 | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
| @ -34,6 +34,7 @@ mod trace_filter; | |||||||
| mod uint; | mod uint; | ||||||
| mod work; | mod work; | ||||||
| mod histogram; | mod histogram; | ||||||
|  | mod consensus_status; | ||||||
| 
 | 
 | ||||||
| pub use self::bytes::Bytes; | pub use self::bytes::Bytes; | ||||||
| pub use self::block::{RichBlock, Block, BlockTransactions}; | pub use self::block::{RichBlock, Block, BlockTransactions}; | ||||||
| @ -55,3 +56,4 @@ pub use self::trace_filter::TraceFilter; | |||||||
| pub use self::uint::{U128, U256}; | pub use self::uint::{U128, U256}; | ||||||
| pub use self::work::Work; | pub use self::work::Work; | ||||||
| pub use self::histogram::Histogram; | pub use self::histogram::Histogram; | ||||||
|  | pub use self::consensus_status::ConsensusCapability; | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user