Unverified Commit 18d2aef0 authored by Roman Zeyde's avatar Roman Zeyde
Browse files

Re-format using Rust 1.29

parent 58ea2ed9
......@@ -248,5 +248,5 @@ pub fn index_blk_files(
store.write(vec![parser.last_indexed_row()]);
store
}).join()
.expect("writer panicked"))
.expect("writer panicked"))
}
......@@ -219,8 +219,9 @@ struct CookieFile {
impl CookieGetter for CookieFile {
fn get(&self) -> Result<Vec<u8>> {
let path = self.daemon_dir.join(".cookie");
let contents = fs::read(&path)
.chain_err(|| ErrorKind::Connection(format!("failed to read cookie from {:?}", path)))?;
let contents = fs::read(&path).chain_err(|| {
ErrorKind::Connection(format!("failed to read cookie from {:?}", path))
})?;
Ok(contents)
}
}
......@@ -34,7 +34,10 @@ fn header_from_value(value: Value) -> Result<BlockHeader> {
.as_str()
.chain_err(|| format!("non-string header: {}", value))?;
let header_bytes = hex::decode(header_hex).chain_err(|| "non-hex header")?;
Ok(deserialize(&header_bytes).chain_err(|| format!("failed to parse header {}", header_hex))?)
Ok(
deserialize(&header_bytes)
.chain_err(|| format!("failed to parse header {}", header_hex))?,
)
}
fn block_from_value(value: Value) -> Result<Block> {
......@@ -203,8 +206,7 @@ impl Connection {
.next()
.chain_err(|| {
ErrorKind::Connection("disconnected from daemon while receiving".to_owned())
})?
.chain_err(|| "failed to read status")?;
})?.chain_err(|| "failed to read status")?;
let mut headers = HashMap::new();
for line in iter {
let line = line.chain_err(|| ErrorKind::Connection("failed to read".to_owned()))?;
......@@ -544,7 +546,8 @@ impl Daemon {
.get("fee")
.chain_err(|| "missing fee")?
.as_f64()
.chain_err(|| "non-float fee")? * 100_000_000f64) as u64;
.chain_err(|| "non-float fee")?
* 100_000_000f64) as u64;
let vsize = entry
.get("size")
.chain_err(|| "missing size")?
......
......@@ -207,8 +207,7 @@ impl Tracker {
None // ignore this transaction for now
}
}
})
.collect();
}).collect();
if entries.is_empty() {
return Ok(());
}
......
......@@ -39,15 +39,12 @@ fn unspent_from_status(status: &Status) -> Value {
status
.unspent()
.into_iter()
.map(|out| {
json!({
.map(|out| json!({
"height": out.height,
"tx_pos": out.output_index,
"tx_hash": out.txn_id.be_hex_string(),
"value": out.value,
})
})
.collect()
})).collect()
))
}
......
......@@ -105,7 +105,8 @@ impl HeaderList {
} else {
self.header_by_blockhash(&prev_blockhash)
.expect(&format!("{} is not part of the blockchain", prev_blockhash))
.height() + 1
.height()
+ 1
};
(new_height..)
.zip(hashed_headers.into_iter())
......@@ -113,8 +114,7 @@ impl HeaderList {
height: height,
hash: hashed_header.blockhash,
header: hashed_header.header,
})
.collect()
}).collect()
}
pub fn apply(&mut self, new_headers: Vec<HeaderEntry>) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment