Skip to content

Commit

Permalink
Merge pull request #6 from paritytech/master
Browse files Browse the repository at this point in the history
update from parity
  • Loading branch information
EighteenZi authored May 12, 2018
2 parents 7037857 + 57d1f2b commit f080d37
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 57 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Official website: https://parity.io | Be sure to check out [our wiki](https://wi

Parity's goal is to be the fastest, lightest, and most secure Ethereum client. We are developing Parity using the sophisticated and cutting-edge Rust programming language. Parity is licensed under the GPLv3, and can be used for all your Ethereum needs.

From Parity Ethereum client version 1.10.0, the User Interface (UI) is accessible in a separate application called Parity UI. To keep using the UI in the browser (deprecated), [follow these steps](https://wiki.parity.io/FAQ-Basic-Operations,-Configuration,-and-Synchronization.md#the-parity-ui-application-isnt-working-the-way-i-want).
From Parity Ethereum client version 1.10.0, the User Interface (UI) is accessible in a separate application called Parity UI. To keep using the UI in the browser (deprecated), [follow these steps](https://wiki.parity.io/FAQ-Basic-Operations,-Configuration,-and-Synchronization#the-parity-ui-application-isnt-working-the-way-i-want).

By default, Parity will also run a JSONRPC server on `127.0.0.1:8545` and a websockets server on `127.0.0.1:8546`. This is fully configurable and supports a number of APIs.

Expand Down
16 changes: 2 additions & 14 deletions dapps/src/page/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
use std::io;
use std::time::{Duration, SystemTime};
use hyper::{self, header, StatusCode};
use hyper::mime::{self, Mime};
use hyper::mime::{Mime};

use apps;
use handlers::{Reader, ContentHandler, add_security_headers};
use {Embeddable};

Expand Down Expand Up @@ -98,18 +97,7 @@ impl<T: DappFile> PageHandler<T> {
add_security_headers(&mut headers, self.safe_to_embed_on, self.allow_js_eval);
}

let initial_content = if file.content_type().to_owned() == mime::TEXT_HTML {
let content = &format!(
r#"<script src="/{}/inject.js"></script>"#,
apps::UTILS_PATH,
);

content.as_bytes().to_vec()
} else {
Vec::new()
};

let (reader, body) = Reader::pair(file.into_reader(), initial_content);
let (reader, body) = Reader::pair(file.into_reader(), Vec::new());
res.set_body(body);
(Some(reader), res)
}
Expand Down
29 changes: 0 additions & 29 deletions dapps/src/tests/home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,32 +60,3 @@ fn should_serve_home() {
response.assert_header("Content-Type", "text/html");
assert_security_headers(&response.headers);
}


#[test]
fn should_inject_js() {
// given
let server = serve_ui();

// when
let response = request(server,
"\
GET / HTTP/1.1\r\n\
Host: 127.0.0.1:8080\r\n\
Connection: close\r\n\
\r\n\
{}
"
);

// then
response.assert_status("HTTP/1.1 200 OK");
response.assert_header("Content-Type", "text/html");
assert_eq!(
response.body.contains(r#"/inject.js"></script>"#),
true,
"Expected inject script tag in: {}",
response.body
);
assert_security_headers(&response.headers);
}
2 changes: 1 addition & 1 deletion ethcore/src/encoded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl Block {
pub fn header_view(&self) -> HeaderView { self.view().header_view() }

/// Decode to a full block.
pub fn decode(&self) -> FullBlock { ::rlp::decode(&self.0).expect("decoding failure") }
pub fn decode(&self) -> Result<FullBlock, rlp::DecoderError> { rlp::decode(&self.0) }

/// Decode the header.
pub fn decode_header(&self) -> FullHeader { self.view().rlp().val_at(0) }
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/snapshot/consensus/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl SnapshotComponents for PoaSnapshot {
let (block, receipts) = chain.block(&block_at)
.and_then(|b| chain.block_receipts(&block_at).map(|r| (b, r)))
.ok_or(Error::BlockNotFound(block_at))?;
let block = block.decode();
let block = block.decode()?;

let parent_td = chain.block_details(block.header.parent_hash())
.map(|d| d.total_difficulty)
Expand Down
2 changes: 1 addition & 1 deletion ethcore/sync/src/light_sync/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

//! Helpers for decoding and verifying responses for headers.
use ethcore::{self, encoded, header::Header};
use ethcore::{encoded, header::Header};
use ethereum_types::H256;
use light::request::{HashOrNumber, CompleteHeadersRequest as HeadersRequest};
use rlp::DecoderError;
Expand Down
9 changes: 4 additions & 5 deletions rpc/src/v1/impls/light/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,9 @@ impl Parity for ParityClient {

let engine = self.light_dispatch.client.engine().clone();
let from_encoded = move |encoded: encoded::Header| {
let header = encoded.decode().expect("decoding error"); // REVIEW: not sure what to do here; what is a decent return value for the error case here?
let header = encoded.decode().map_err(errors::decode)?;
let extra_info = engine.extra_info(&header);
RichHeader {
Ok(RichHeader {
inner: Header {
hash: Some(header.hash().into()),
size: Some(encoded.rlp().as_raw().len().into()),
Expand All @@ -418,9 +418,8 @@ impl Parity for ParityClient {
extra_data: Bytes::new(header.extra_data().clone()),
},
extra_info: extra_info,
}
})
};

// Note: Here we treat `Pending` as `Latest`.
// Since light clients don't produce pending blocks
// (they don't have state) we can safely fallback to `Latest`.
Expand All @@ -430,7 +429,7 @@ impl Parity for ParityClient {
BlockNumber::Latest | BlockNumber::Pending => BlockId::Latest,
};

Box::new(self.fetcher().header(id).map(from_encoded))
Box::new(self.fetcher().header(id).and_then(from_encoded))
}

fn ipfs_cid(&self, content: Bytes) -> Result<String> {
Expand Down
7 changes: 6 additions & 1 deletion util/io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,12 @@ mod tests {
use std::time::Duration;
use super::*;

// Mio's behaviour is too unstable for this test. Sometimes we have to wait a few milliseconds,
// sometimes more than 5 seconds for the message to arrive.
// Therefore we ignore this test in order to not have spurious failure when running continuous
// integration.
#[test]
#[cfg_attr(feature = "mio", ignore)]
fn send_message_to_handler() {
struct MyHandler(atomic::AtomicBool);

Expand All @@ -209,7 +214,7 @@ mod tests {

service.send_message(MyMessage { data: 5 }).unwrap();

thread::sleep(Duration::from_secs(5));
thread::sleep(Duration::from_secs(1));
assert!(handler.0.load(atomic::Ordering::SeqCst));
}

Expand Down
6 changes: 3 additions & 3 deletions util/journaldb/src/earlymergedb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ enum RemoveFrom {
/// the removals actually take effect.
///
/// journal format:
/// ```
/// ```text
/// [era, 0] => [ id, [insert_0, ...], [remove_0, ...] ]
/// [era, 1] => [ id, [insert_0, ...], [remove_0, ...] ]
/// [era, n] => [ ... ]
Expand All @@ -76,7 +76,7 @@ enum RemoveFrom {
/// which includes an original key, if any.
///
/// The semantics of the `counter` are:
/// ```
/// ```text
/// insert key k:
/// counter already contains k: count += 1
/// counter doesn't contain k:
Expand All @@ -92,7 +92,7 @@ enum RemoveFrom {
///
/// Practically, this means that for each commit block turning from recent to ancient we do the
/// following:
/// ```
/// ```text
/// is_canonical:
/// inserts: Ignored (left alone in the backing database).
/// deletes: Enacted; however, recent history queue is checked for ongoing references. This is
Expand Down
2 changes: 1 addition & 1 deletion util/journaldb/src/refcounteddb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use util::{DatabaseKey, DatabaseValueView, DatabaseValueRef};
/// the removals actually take effect.
///
/// journal format:
/// ```
/// ```text
/// [era, 0] => [ id, [insert_0, ...], [remove_0, ...] ]
/// [era, 1] => [ id, [insert_0, ...], [remove_0, ...] ]
/// [era, n] => [ ... ]
Expand Down

0 comments on commit f080d37

Please sign in to comment.