5 random fixes (#2) (#623)

* Tabs instead of spaces.

* Remove double spaces.

* Add spaces between ID and the following {

* Update to nightly 2018-08-27

* Align wat code properly
This commit is contained in:
Sergey Pepyakin
2018-08-29 12:26:44 +03:00
committed by Gav Wood
parent 5c8b52ba16
commit 283eb383c0
27 changed files with 105 additions and 105 deletions
+1 -1
View File
@@ -25,5 +25,5 @@ error_chain! {
}
links {
Client(client::error::Error, client::error::ErrorKind) #[doc="Client error"];
}
}
}
+1 -1
View File
@@ -95,7 +95,7 @@ impl extrinsic_pool::ChainApi for Pool {
unimplemented!()
}
fn ready(&self) -> Self::Ready { }
fn ready(&self) -> Self::Ready { }
fn is_ready(&self, _at: &BlockId, _ready: &mut Self::Ready, _xt: &VerifiedFor<Self>) -> Readiness {
unimplemented!()
+8 -8
View File
@@ -137,7 +137,7 @@ mod tests {
#[test]
fn test_score_1_char_100() {
let score = calculate_score("j", "5jolkadotwHY5k9GpdTgpqs9xjuNvtv8EcwCFpEeyEf3KHim");
assert!(score == 100, format!("Wrong score, we found {}", score));
assert!(score == 100, format!("Wrong score, we found {}", score));
}
#[test]
@@ -159,17 +159,17 @@ mod tests {
#[cfg(feature = "bench")]
#[bench]
fn bench_paranoiac(b: &mut Bencher) {
b.iter(|| {
fn bench_paranoiac(b: &mut Bencher) {
b.iter(|| {
generate_key("polka", 3, true)
});
}
}
#[cfg(feature = "bench")]
#[bench]
fn bench_not_paranoiac(b: &mut Bencher) {
b.iter(|| {
#[bench]
fn bench_not_paranoiac(b: &mut Bencher) {
b.iter(|| {
generate_key("polka", 3, false)
});
}
}
}
+1 -1
View File
@@ -26,7 +26,7 @@ error_chain! {
}
links {
Client(client::error::Error, client::error::ErrorKind) #[doc="Client error"];
}
}
errors {
/// Input error.
Input(m: String) {
+1 -1
View File
@@ -455,7 +455,7 @@ impl<Block> client::backend::Backend<Block, KeccakHasher, RlpCodec> for Backend<
}
self.blockchain.header(block).and_then(|maybe_hdr| maybe_hdr.map(|hdr| {
let root: H256 = H256::from_slice(hdr.state_root().as_ref());
let root: H256 = H256::from_slice(hdr.state_root().as_ref());
DbState::with_storage(self.storage.clone(), root)
}).ok_or_else(|| client::error::ErrorKind::UnknownBlock(format!("{:?}", block)).into()))
}
@@ -136,7 +136,7 @@ where
call_data,
native_when_possible(),
)?;
Ok(CallResult{ return_data, changes })
Ok(CallResult { return_data, changes })
}
fn runtime_version(&self, id: &BlockId<Block>) -> error::Result<RuntimeVersion> {
@@ -132,7 +132,7 @@ impl<S, F, Block, H, C> BlockImportOperation<Block, H, C> for ImportOperation<Bl
where
Block: BlockT,
F: Fetcher<Block>,
S: BlockchainStorage<Block>,
S: BlockchainStorage<Block>,
H: Hasher,
C: NodeCodec<H>,
{
@@ -175,8 +175,8 @@ impl<Block, S, F, H, C> StateBackend<H, C> for OnDemandState<Block, S, F>
Block: BlockT,
S: BlockchainStorage<Block>,
F: Fetcher<Block>,
H: Hasher,
C: NodeCodec<H>,
H: Hasher,
C: NodeCodec<H>,
{
type Error = ClientError;
type Transaction = ();
+1 -1
View File
@@ -69,7 +69,7 @@ pub fn new_fetch_checker<E, H, C>(
) -> LightDataChecker<E, H, C>
where
E: CodeExecutor<H>,
H: Hasher,
H: Hasher,
C: NodeCodec<H>,
{
LightDataChecker::new(executor)
+1 -1
View File
@@ -1,5 +1,5 @@
#![no_std]
#![feature(panic_implementation)]
#![feature(panic_handler)]
#![cfg_attr(feature = "strict", deny(warnings))]
#![feature(alloc)]
@@ -248,7 +248,7 @@ impl<B: ChainApi> Pool<B> {
}
/// Imports one unverified extrinsic to the pool
pub fn submit_one(&self, at: &BlockId<B::Block>, xt: ExtrinsicFor<B>) -> Result<Arc<VerifiedFor<B>>, B::Error> {
pub fn submit_one(&self, at: &BlockId<B::Block>, xt: ExtrinsicFor<B>) -> Result<Arc<VerifiedFor<B>>, B::Error> {
Ok(self.submit_at(at, ::std::iter::once(xt))?.pop().expect("One extrinsic passed; one result returned; qed"))
}
@@ -677,7 +677,7 @@ impl NetworkState {
}
/// Disables a peer for `PEER_DISABLE_DURATION`. This adds the peer to the
/// list of disabled peers, and drops any existing connections if
/// list of disabled peers, and drops any existing connections if
/// necessary (ie. drops the sender that was stored in the `UniqueConnec`
/// of `custom_proto`).
pub fn ban_peer(&self, who: NodeIndex, reason: &str) {
@@ -864,7 +864,7 @@ fn handle_custom_connection(
/// nodes and only accept incoming connections.
fn start_kademlia_discovery<T, To, St, C>(shared: Arc<Shared>, transport: T,
swarm_controller: SwarmController<St>) -> impl Future<Item = (), Error = IoError>
where T: MuxedTransport<Output = TransportOutput<To>> + Clone + 'static,
where T: MuxedTransport<Output = TransportOutput<To>> + Clone + 'static,
T::MultiaddrFuture: 'static,
To: AsyncRead + AsyncWrite + 'static,
St: MuxedTransport<Output = FinalUpgrade<C>> + Clone + 'static,
@@ -931,7 +931,7 @@ fn perform_kademlia_query<T, To, St, C>(
transport: T,
swarm_controller: SwarmController<St>
) -> impl Future<Item = (), Error = IoError>
where T: MuxedTransport<Output = TransportOutput<To>> + Clone + 'static,
where T: MuxedTransport<Output = TransportOutput<To>> + Clone + 'static,
T::MultiaddrFuture: 'static,
To: AsyncRead + AsyncWrite + 'static,
St: MuxedTransport<Output = FinalUpgrade<C>> + Clone + 'static,
@@ -980,7 +980,7 @@ fn connect_to_nodes<T, To, St, C>(
base_transport: T,
swarm_controller: &SwarmController<St>
)
where T: MuxedTransport<Output = TransportOutput<To>> + Clone + 'static,
where T: MuxedTransport<Output = TransportOutput<To>> + Clone + 'static,
T::MultiaddrFuture: 'static,
To: AsyncRead + AsyncWrite + 'static,
St: MuxedTransport<Output = FinalUpgrade<C>> + Clone + 'static,
@@ -1025,7 +1025,7 @@ fn connect_with_query_peer_id<T, To, St, C>(
addr: Multiaddr,
swarm_controller: &SwarmController<St>
)
where T: MuxedTransport<Output = TransportOutput<To>> + Clone + 'static,
where T: MuxedTransport<Output = TransportOutput<To>> + Clone + 'static,
T::MultiaddrFuture: 'static,
To: AsyncRead + AsyncWrite + 'static,
St: MuxedTransport<Output = FinalUpgrade<C>> + Clone + 'static,
@@ -1087,7 +1087,7 @@ fn open_peer_custom_proto<T, To, St, C>(
expected_peer_id: PeerstorePeerId,
swarm_controller: &SwarmController<St>
)
where T: MuxedTransport<Output = TransportOutput<To>> + Clone + 'static,
where T: MuxedTransport<Output = TransportOutput<To>> + Clone + 'static,
T::MultiaddrFuture: 'static,
To: AsyncRead + AsyncWrite + 'static,
St: MuxedTransport<Output = FinalUpgrade<C>> + Clone + 'static,
@@ -1177,7 +1177,7 @@ fn open_peer_custom_proto<T, To, St, C>(
fn obtain_kad_connection<T, To, St, C>(shared: Arc<Shared>,
who: PeerstorePeerId, transport: T, swarm_controller: SwarmController<St>)
-> impl Future<Item = KadConnecController, Error = IoError>
where T: MuxedTransport<Output = TransportOutput<To>> + Clone + 'static,
where T: MuxedTransport<Output = TransportOutput<To>> + Clone + 'static,
T::MultiaddrFuture: 'static,
To: AsyncRead + AsyncWrite + 'static,
St: MuxedTransport<Output = FinalUpgrade<C>> + Clone + 'static,
+4 -4
View File
@@ -106,7 +106,7 @@ impl<B: BlockT> BlockCollection<B> {
loop {
let next = downloading_iter.next();
break match &(prev, next) {
&(Some((start, &BlockRangeState::Downloading { ref len, downloading })), _) if downloading < MAX_PARALLEL_DOWNLOADS =>
&(Some((start, &BlockRangeState::Downloading { ref len, downloading })), _) if downloading < MAX_PARALLEL_DOWNLOADS =>
(*start .. *start + *len, downloading),
&(Some((start, r)), Some((next_start, _))) if *start + r.len() < *next_start =>
(*start + r.len() .. cmp::min(*next_start, *start + r.len() + count), 0), // gap
@@ -130,7 +130,7 @@ impl<B: BlockT> BlockCollection<B> {
}
range.end = cmp::min(peer_best + As::sa(1), range.end);
self.peer_requests.insert(who, range.start);
self.blocks.insert(range.start, BlockRangeState::Downloading{ len: range.end - range.start, downloading: downloading + 1 });
self.blocks.insert(range.start, BlockRangeState::Downloading { len: range.end - range.start, downloading: downloading + 1 });
if range.end <= range.start {
panic!("Empty range {:?}, count={}, peer_best={}, common={}, blocks={:?}", range, count, peer_best, common, self.blocks);
}
@@ -171,7 +171,7 @@ impl<B: BlockT> BlockCollection<B> {
*downloading = *downloading - 1;
false
},
Some(&mut BlockRangeState::Downloading { .. }) => {
Some(&mut BlockRangeState::Downloading { .. }) => {
true
},
_ => {
@@ -217,7 +217,7 @@ mod test {
fn create_clear() {
let mut bc = BlockCollection::new();
assert!(is_empty(&bc));
bc.insert(1, generate_blocks(100), 0);
bc.insert(1, generate_blocks(100), 0);
assert!(!is_empty(&bc));
bc.clear();
assert!(is_empty(&bc));
+2 -2
View File
@@ -191,7 +191,7 @@ impl<B: BlockT, S: Specialization<B>, H: ExHashT> Protocol<B, S, H> {
on_demand: Option<Arc<OnDemandService<B>>>,
transaction_pool: Arc<TransactionPool<H, B>>,
specialization: S,
) -> error::Result<Self> {
) -> error::Result<Self> {
let info = chain.info()?;
let sync = ChainSync::new(config.roles, &info, import_queue);
let protocol = Protocol {
@@ -321,7 +321,7 @@ impl<B: BlockT, S: Specialization<B>, H: ExHashT> Protocol<B, S, H> {
let get_body = request.fields.contains(message::BlockAttributes::BODY);
let get_justification = request.fields.contains(message::BlockAttributes::JUSTIFICATION);
while let Some(header) = self.context_data.chain.header(&id).unwrap_or(None) {
if blocks.len() >= max{
if blocks.len() >= max {
break;
}
let number = header.number().clone();
+1 -1
View File
@@ -108,7 +108,7 @@ pub fn deserialize_check_len<'de, D>(deserializer: D, len: ExpectedLen) -> Resul
}
fn visit_str<E: de::Error>(self, v: &str) -> Result<Self::Value, E> {
if v.len() < 2 || &v[0..2] != "0x" {
if v.len() < 2 || &v[0..2] != "0x" {
return Err(E::custom("prefix is missing"))
}
+43 -43
View File
@@ -77,53 +77,53 @@ impl NodeCodec<KeccakHasher> for RlpCodec {
fn is_empty_node(data: &[u8]) -> bool {
Rlp::new(data).is_empty()
}
fn empty_node() -> ElasticArray1024<u8> {
let mut stream = RlpStream::new();
stream.append_empty_data();
stream.drain()
}
fn leaf_node(partial: &[u8], value: &[u8]) -> ElasticArray1024<u8> {
let mut stream = RlpStream::new_list(2);
stream.append(&partial);
stream.append(&value);
fn empty_node() -> ElasticArray1024<u8> {
let mut stream = RlpStream::new();
stream.append_empty_data();
stream.drain()
}
}
fn leaf_node(partial: &[u8], value: &[u8]) -> ElasticArray1024<u8> {
let mut stream = RlpStream::new_list(2);
stream.append(&partial);
stream.append(&value);
stream.drain()
}
fn ext_node(partial: &[u8], child_ref: ChildReference<<KeccakHasher as Hasher>::Out>) -> ElasticArray1024<u8> {
let mut stream = RlpStream::new_list(2);
stream.append(&partial);
match child_ref {
ChildReference::Hash(h) => stream.append(&h),
ChildReference::Inline(inline_data, len) => {
let bytes = &AsRef::<[u8]>::as_ref(&inline_data)[..len];
stream.append_raw(bytes, 1)
},
};
stream.drain()
let mut stream = RlpStream::new_list(2);
stream.append(&partial);
match child_ref {
ChildReference::Hash(h) => stream.append(&h),
ChildReference::Inline(inline_data, len) => {
let bytes = &AsRef::<[u8]>::as_ref(&inline_data)[..len];
stream.append_raw(bytes, 1)
},
};
stream.drain()
}
fn branch_node<I>(children: I, value: Option<ElasticArray128<u8>>) -> ElasticArray1024<u8>
where I: IntoIterator<Item=Option<ChildReference<<KeccakHasher as Hasher>::Out>>>
{
let mut stream = RlpStream::new_list(17);
for child_ref in children {
match child_ref {
Some(c) => match c {
ChildReference::Hash(h) => stream.append(&h),
ChildReference::Inline(inline_data, len) => {
let bytes = &AsRef::<[u8]>::as_ref(&inline_data)[..len];
stream.append_raw(bytes, 1)
},
},
None => stream.append_empty_data()
};
}
if let Some(value) = value {
stream.append(&&*value);
} else {
stream.append_empty_data();
}
stream.drain()
}
}
{
let mut stream = RlpStream::new_list(17);
for child_ref in children {
match child_ref {
Some(c) => match c {
ChildReference::Hash(h) => stream.append(&h),
ChildReference::Inline(inline_data, len) => {
let bytes = &AsRef::<[u8]>::as_ref(&inline_data)[..len];
stream.append_raw(bytes, 1)
},
},
None => stream.append_empty_data()
};
}
if let Some(value) = value {
stream.append(&&*value);
} else {
stream.append_empty_data();
}
stream.drain()
}
}
+1 -1
View File
@@ -56,7 +56,7 @@ impl ChainApi for TestApi {
fn verify_transaction(&self, _at: &BlockId<Block>, uxt: &ExtrinsicFor<Self>) -> Result<Self::VEx, Self::Error> {
Ok(Verified {
sender: uxt.transfer.from[31] as u64,
hash: uxt.transfer.nonce,
hash: uxt.transfer.nonce,
})
}
+1 -1
View File
@@ -18,7 +18,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(lang_items))]
#![cfg_attr(not(feature = "std"), feature(panic_implementation))]
#![cfg_attr(not(feature = "std"), feature(panic_handler))]
#![cfg_attr(not(feature = "std"), feature(alloc_error_handler))]
#![cfg_attr(not(feature = "std"), feature(core_intrinsics))]
#![cfg_attr(not(feature = "std"), feature(alloc))]
@@ -27,7 +27,7 @@ use core::intrinsics;
use rstd::vec::Vec;
pub use rstd::{mem, slice};
#[panic_implementation]
#[panic_handler]
#[no_mangle]
pub fn panic(info: &::core::panic::PanicInfo) -> ! {
unsafe {
@@ -37,7 +37,7 @@
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(panic_implementation))]
#![cfg_attr(not(feature = "std"), feature(panic_handler))]
#![cfg_attr(not(feature = "std"), feature(core_intrinsics))]
#![cfg_attr(not(feature = "std"), feature(alloc))]
+1 -1
View File
@@ -18,7 +18,7 @@
//! or core/alloc to be used with any code that depends on the runtime.
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(panic_implementation))]
#![cfg_attr(not(feature = "std"), feature(panic_handler))]
#![cfg_attr(not(feature = "std"), feature(core_intrinsics))]
#![cfg_attr(not(feature = "std"), feature(alloc))]
@@ -332,27 +332,27 @@ mod tests {
const CODE_TRANSFER: &str = r#"
(module
;; ext_transfer(transfer_to: u32, transfer_to_len: u32, value_ptr: u32, value_len: u32)
(import "env" "ext_transfer" (func $ext_transfer (param i32 i32 i32 i32)))
;; ext_transfer(transfer_to: u32, transfer_to_len: u32, value_ptr: u32, value_len: u32)
(import "env" "ext_transfer" (func $ext_transfer (param i32 i32 i32 i32)))
(import "env" "memory" (memory 1 1))
(import "env" "memory" (memory 1 1))
(func (export "call")
(call $ext_transfer
(i32.const 4) ;; Pointer to "Transfer to" address.
(i32.const 8) ;; Length of "Transfer to" address.
(i32.const 12) ;; Pointer to the buffer with value to transfer
(func (export "call")
(call $ext_transfer
(i32.const 4) ;; Pointer to "Transfer to" address.
(i32.const 8) ;; Length of "Transfer to" address.
(i32.const 12) ;; Pointer to the buffer with value to transfer
(i32.const 8) ;; Length of the buffer with value to transfer.
)
)
)
)
;; Destination AccountId to transfer the funds.
;; Represented by u64 (8 bytes long) in little endian.
(data (i32.const 4) "\02\00\00\00\00\00\00\00")
;; Amount of value to transfer.
;; Destination AccountId to transfer the funds.
;; Represented by u64 (8 bytes long) in little endian.
(data (i32.const 12) "\06\00\00\00\00\00\00\00")
(data (i32.const 4) "\02\00\00\00\00\00\00\00")
;; Amount of value to transfer.
;; Represented by u64 (8 bytes long) in little endian.
(data (i32.const 12) "\06\00\00\00\00\00\00\00")
)
"#;
@@ -41,7 +41,7 @@ pub type NetworkService<F> = network::Service<
>;
/// Code executor type for a factory.
pub type CodeExecutor<F> = NativeExecutor<<F as ServiceFactory>::RuntimeDispatch>;
pub type CodeExecutor<F> = NativeExecutor<<F as ServiceFactory>::RuntimeDispatch>;
/// Full client backend type for a factory.
pub type FullBackend<F> = client_db::Backend<<F as ServiceFactory>::Block>;
@@ -114,7 +114,7 @@ impl<BlockHash: Hash, Key: Hash> UnfinalizedOverlay<BlockHash, Key> {
pub fn insert(&mut self, hash: &BlockHash, number: u64, parent_hash: &BlockHash, changeset: ChangeSet<Key>) -> CommitSet<Key> {
let mut commit = CommitSet::default();
if self.levels.is_empty() && self.last_finalized.is_none() {
// assume that parent was finalized
// assume that parent was finalized
let last_finalized = (parent_hash.clone(), number - 1);
commit.meta.inserted.push((to_meta_key(LAST_FINALIZED, &()), last_finalized.encode()));
self.last_finalized = Some(last_finalized);
@@ -272,7 +272,7 @@ mod tests {
#[test]
fn created_from_empty_db() {
let db = make_db(&[]);
let overlay: UnfinalizedOverlay<H256, H256> = UnfinalizedOverlay::new(&db).unwrap();
let overlay: UnfinalizedOverlay<H256, H256> = UnfinalizedOverlay::new(&db).unwrap();
assert_eq!(overlay.last_finalized, None);
assert!(overlay.levels.is_empty());
assert!(overlay.parents.is_empty());
+1 -1
View File
@@ -155,7 +155,7 @@ where
}
fn storage_root(&mut self) -> H::Out {
if let Some((_, ref root)) = self.transaction {
if let Some((_, ref root)) = self.transaction {
return root.clone();
}
+1 -1
View File
@@ -619,7 +619,7 @@ mod tests {
&mut Default::default(), &executor, "test", &[]).unwrap();
// check proof locally
let (local_result, _) = execution_proof_check::<KeccakHasher, RlpCodec,_,>(remote_root, remote_proof,
let (local_result, _) = execution_proof_check::<KeccakHasher, RlpCodec,_,>(remote_root, remote_proof,
&mut Default::default(), &executor, "test", &[]).unwrap();
// check that both results are correct
@@ -291,9 +291,9 @@ pub mod tests {
trie.insert(b"value1", &[42]).expect("insert failed");
trie.insert(b"value2", &[24]).expect("insert failed");
trie.insert(b":code", b"return 42").expect("insert failed");
for i in 128u8..255u8 {
trie.insert(&[i], &[i]).unwrap();
}
for i in 128u8..255u8 {
trie.insert(&[i], &[i]).unwrap();
}
}
(mdb, root)
}