From 6980278b95d266f6a420b64052ab6231a6e1c466 Mon Sep 17 00:00:00 2001 From: yeastplume Date: Thu, 18 Oct 2018 11:23:22 +0100 Subject: [PATCH] merge T4 into master - rustfmt --- chain/src/txhashset/txhashset.rs | 4 +--- chain/tests/test_txhashset.rs | 9 +++------ core/src/core/id.rs | 24 ++++++++++++------------ core/src/core/transaction.rs | 6 +++--- core/src/core/verifier_cache.rs | 6 ++---- core/src/genesis.rs | 9 ++++----- core/src/global.rs | 5 ++--- core/src/pow/common.rs | 11 ++--------- core/src/pow/cuckatoo.rs | 10 ++-------- core/src/pow/cuckoo.rs | 18 ++++++------------ core/src/pow/types.rs | 13 +++---------- core/tests/consensus.rs | 12 ++++++------ keychain/src/extkey_bip32.rs | 3 ++- keychain/src/keychain.rs | 9 +++------ servers/src/grin/seed.rs | 2 +- src/bin/tui/menu.rs | 6 ++---- wallet/src/file_wallet.rs | 6 +++--- wallet/src/libwallet/controller.rs | 20 ++++++++++---------- wallet/src/libwallet/error.rs | 12 ++++++++++-- wallet/src/libwallet/internal/updater.rs | 6 ++---- wallet/src/lmdb_wallet.rs | 6 +++++- wallet/tests/libwallet.rs | 9 +++------ wallet/tests/transaction.rs | 4 ++-- 23 files changed, 89 insertions(+), 121 deletions(-) diff --git a/chain/src/txhashset/txhashset.rs b/chain/src/txhashset/txhashset.rs index 16e2dbbad..19a739ad0 100644 --- a/chain/src/txhashset/txhashset.rs +++ b/chain/src/txhashset/txhashset.rs @@ -851,9 +851,7 @@ impl<'a> Extension<'a> { // Find the "cutoff" pos in the output MMR based on the // header from 1,000 blocks ago. - let cutoff_height = height - .checked_sub(global::coinbase_maturity()) - .unwrap_or(0); + let cutoff_height = height.checked_sub(global::coinbase_maturity()).unwrap_or(0); let cutoff_header = self.batch.get_header_by_height(cutoff_height)?; let cutoff_pos = cutoff_header.output_mmr_size; diff --git a/chain/tests/test_txhashset.rs b/chain/tests/test_txhashset.rs index 948a1620e..0d48b1958 100644 --- a/chain/tests/test_txhashset.rs +++ b/chain/tests/test_txhashset.rs @@ -82,8 +82,7 @@ fn write_file(db_root: String) { .join("txhashset") .join("kernel") .join("strange0"), - ) - .unwrap(); + ).unwrap(); OpenOptions::new() .create(true) .write(true) @@ -98,8 +97,7 @@ fn write_file(db_root: String) { .join("txhashset") .join("strange_dir") .join("strange2"), - ) - .unwrap(); + ).unwrap(); fs::create_dir( Path::new(&db_root) .join("txhashset") @@ -115,8 +113,7 @@ fn write_file(db_root: String) { .join("strange_dir") .join("strange_subdir") .join("strange3"), - ) - .unwrap(); + ).unwrap(); } fn txhashset_contains_expected_files(dirname: String, path_buf: PathBuf) -> bool { diff --git a/core/src/core/id.rs b/core/src/core/id.rs index 67a66549d..4626b5109 100644 --- a/core/src/core/id.rs +++ b/core/src/core/id.rs @@ -170,9 +170,9 @@ mod test { let foo = Foo(0); - let expected_hash = Hash::from_hex( - "81e47a19e6b29b0a65b9591762ce5143ed30d0261e5d24a3201752506b20f15c", - ).unwrap(); + let expected_hash = + Hash::from_hex("81e47a19e6b29b0a65b9591762ce5143ed30d0261e5d24a3201752506b20f15c") + .unwrap(); assert_eq!(foo.hash(), expected_hash); let other_hash = Hash::default(); @@ -182,9 +182,9 @@ mod test { ); let foo = Foo(5); - let expected_hash = Hash::from_hex( - "3a42e66e46dd7633b57d1f921780a1ac715e6b93c19ee52ab714178eb3a9f673", - ).unwrap(); + let expected_hash = + Hash::from_hex("3a42e66e46dd7633b57d1f921780a1ac715e6b93c19ee52ab714178eb3a9f673") + .unwrap(); assert_eq!(foo.hash(), expected_hash); let other_hash = Hash::default(); @@ -194,14 +194,14 @@ mod test { ); let foo = Foo(5); - let expected_hash = Hash::from_hex( - "3a42e66e46dd7633b57d1f921780a1ac715e6b93c19ee52ab714178eb3a9f673", - ).unwrap(); + let expected_hash = + Hash::from_hex("3a42e66e46dd7633b57d1f921780a1ac715e6b93c19ee52ab714178eb3a9f673") + .unwrap(); assert_eq!(foo.hash(), expected_hash); - let other_hash = Hash::from_hex( - "81e47a19e6b29b0a65b9591762ce5143ed30d0261e5d24a3201752506b20f15c", - ).unwrap(); + let other_hash = + Hash::from_hex("81e47a19e6b29b0a65b9591762ce5143ed30d0261e5d24a3201752506b20f15c") + .unwrap(); assert_eq!( foo.short_id(&other_hash, foo.0), ShortId::from_hex("3e9cde72a687").unwrap() diff --git a/core/src/core/transaction.rs b/core/src/core/transaction.rs index ff3d216d7..37bdce30e 100644 --- a/core/src/core/transaction.rs +++ b/core/src/core/transaction.rs @@ -1278,9 +1278,9 @@ mod test { commit: commit, }; - let block_hash = Hash::from_hex( - "3a42e66e46dd7633b57d1f921780a1ac715e6b93c19ee52ab714178eb3a9f673", - ).unwrap(); + let block_hash = + Hash::from_hex("3a42e66e46dd7633b57d1f921780a1ac715e6b93c19ee52ab714178eb3a9f673") + .unwrap(); let nonce = 0; diff --git a/core/src/core/verifier_cache.rs b/core/src/core/verifier_cache.rs index d2bcd7ee9..72a2e9c68 100644 --- a/core/src/core/verifier_cache.rs +++ b/core/src/core/verifier_cache.rs @@ -69,8 +69,7 @@ impl VerifierCache for LruVerifierCache { .kernel_sig_verification_cache .get_mut(&x.hash()) .unwrap_or(&mut false) - }) - .cloned() + }).cloned() .collect::>(); debug!( LOGGER, @@ -89,8 +88,7 @@ impl VerifierCache for LruVerifierCache { .rangeproof_verification_cache .get_mut(&x.proof.hash()) .unwrap_or(&mut false) - }) - .cloned() + }).cloned() .collect::>(); debug!( LOGGER, diff --git a/core/src/genesis.rs b/core/src/genesis.rs index 98c821744..d2994fcf5 100644 --- a/core/src/genesis.rs +++ b/core/src/genesis.rs @@ -119,11 +119,10 @@ pub fn genesis_testnet4() -> core::Block { proof: Proof::new(vec![ 0x46f3b4, 0x1135f8c, 0x1a1596f, 0x1e10f71, 0x41c03ea, 0x63fe8e7, 0x65af34f, 0x73c16d3, 0x8216dc3, 0x9bc75d0, 0xae7d9ad, 0xc1cb12b, 0xc65e957, 0xf67a152, - 0xfac6559, 0x100c3d71, 0x11eea08b, 0x1225dfbb, 0x124d61a1, 0x132a14b4, - 0x13f4ec38, 0x1542d236, 0x155f2df0, 0x1577394e, 0x163c3513, 0x19349845, - 0x19d46953, 0x19f65ed4, 0x1a0411b9, 0x1a2fa039, 0x1a72a06c, 0x1b02ddd2, - 0x1b594d59, 0x1b7bffd3, 0x1befe12e, 0x1c82e4cd, 0x1d492478, 0x1de132a5, - 0x1e578b3c, 0x1ed96855, 0x1f222896, 0x1fea0da6, + 0xfac6559, 0x100c3d71, 0x11eea08b, 0x1225dfbb, 0x124d61a1, 0x132a14b4, 0x13f4ec38, + 0x1542d236, 0x155f2df0, 0x1577394e, 0x163c3513, 0x19349845, 0x19d46953, 0x19f65ed4, + 0x1a0411b9, 0x1a2fa039, 0x1a72a06c, 0x1b02ddd2, 0x1b594d59, 0x1b7bffd3, 0x1befe12e, + 0x1c82e4cd, 0x1d492478, 0x1de132a5, 0x1e578b3c, 0x1ed96855, 0x1f222896, 0x1fea0da6, ]), }, ..Default::default() diff --git a/core/src/global.rs b/core/src/global.rs index c3ad5650c..bb1e6baa7 100644 --- a/core/src/global.rs +++ b/core/src/global.rs @@ -19,8 +19,7 @@ use consensus::HeaderInfo; use consensus::{ graph_weight, BASE_EDGE_BITS, BLOCK_TIME_SEC, COINBASE_MATURITY, CUT_THROUGH_HORIZON, - DAY_HEIGHT, DIFFICULTY_ADJUST_WINDOW, INITIAL_DIFFICULTY, PROOFSIZE, - SECOND_POW_EDGE_BITS, + DAY_HEIGHT, DIFFICULTY_ADJUST_WINDOW, INITIAL_DIFFICULTY, PROOFSIZE, SECOND_POW_EDGE_BITS, }; use pow::{self, CuckatooContext, EdgeType, PoWContext}; /// An enum collecting sets of parameters used throughout the @@ -72,7 +71,7 @@ pub const STUCK_PEER_KICK_TIME: i64 = 2 * 3600 * 1000; /// Testnet 4 initial block difficulty /// 1_000 times natural scale factor for cuckatoo29 -pub const TESTNET4_INITIAL_DIFFICULTY: u64 = 1_000 * (2<<(29-24)) * 29; +pub const TESTNET4_INITIAL_DIFFICULTY: u64 = 1_000 * (2 << (29 - 24)) * 29; /// Trigger compaction check on average every day for FAST_SYNC_NODE, /// roll the dice on every block to decide, diff --git a/core/src/pow/common.rs b/core/src/pow/common.rs index 7c5ef03e6..c94dda948 100644 --- a/core/src/pow/common.rs +++ b/core/src/pow/common.rs @@ -149,10 +149,7 @@ where T: EdgeType, { /// Instantiates new params and calculate edge mask, etc - pub fn new( - edge_bits: u8, - proof_size: usize, - ) -> Result, Error> { + pub fn new(edge_bits: u8, proof_size: usize) -> Result, Error> { let num_edges = (1 as u64) << edge_bits; let edge_mask = to_edge!(num_edges - 1); Ok(CuckooParams { @@ -165,11 +162,7 @@ where } /// Reset the main keys used for siphash from the header and nonce - pub fn reset_header_nonce( - &mut self, - header: Vec, - nonce: Option, - ) -> Result<(), Error> { + pub fn reset_header_nonce(&mut self, header: Vec, nonce: Option) -> Result<(), Error> { self.siphash_keys = set_header_nonce(header, nonce)?; Ok(()) } diff --git a/core/src/pow/cuckatoo.rs b/core/src/pow/cuckatoo.rs index 0cadcb686..189cc1482 100644 --- a/core/src/pow/cuckatoo.rs +++ b/core/src/pow/cuckatoo.rs @@ -165,15 +165,9 @@ impl PoWContext for CuckatooContext where T: EdgeType, { - fn new( - edge_bits: u8, - proof_size: usize, - max_sols: u32, - ) -> Result, Error> { + fn new(edge_bits: u8, proof_size: usize, max_sols: u32) -> Result, Error> { Ok(Box::new(CuckatooContext::::new_impl( - edge_bits, - proof_size, - max_sols, + edge_bits, proof_size, max_sols, )?)) } diff --git a/core/src/pow/cuckoo.rs b/core/src/pow/cuckoo.rs index afe863ece..c6afc6fe8 100644 --- a/core/src/pow/cuckoo.rs +++ b/core/src/pow/cuckoo.rs @@ -40,15 +40,9 @@ impl PoWContext for CuckooContext where T: EdgeType, { - fn new( - edge_bits: u8, - proof_size: usize, - max_sols: u32, - ) -> Result, Error> { + fn new(edge_bits: u8, proof_size: usize, max_sols: u32) -> Result, Error> { Ok(Box::new(CuckooContext::::new_impl( - edge_bits, - proof_size, - max_sols, + edge_bits, proof_size, max_sols, )?)) } @@ -324,21 +318,21 @@ mod test { 0x4cef6, 0x4dfdf, 0x5036b, 0x5d528, 0x7d76b, 0x80958, 0x81649, 0x8a064, 0x935fe, 0x93c28, 0x93fc9, 0x9aec5, 0x9c5c8, 0xa00a7, 0xa7256, 0xaa35e, 0xb9e04, 0xc8835, 0xcda49, 0xd72ea, 0xd7f80, 0xdaa3a, 0xdafce, 0xe03fe, 0xe55a2, 0xe6e60, 0xebb9d, 0xf5248, 0xf6a4b, 0xf6d32, - 0xf7c61, 0xfd9e9 + 0xf7c61, 0xfd9e9, ]; static V2: [u64; 42] = [ 0xab0, 0x403c, 0x509c, 0x127c0, 0x1a0b3, 0x1ffe4, 0x26180, 0x2a20a, 0x35559, 0x36dd3, 0x3cb20, 0x4992f, 0x55b20, 0x5b507, 0x66e58, 0x6784d, 0x6fda8, 0x7363d, 0x76dd6, 0x7f13b, 0x84672, 0x85724, 0x991cf, 0x9a6fe, 0x9b0c5, 0xa5019, 0xa7207, 0xaf32f, 0xc29f3, 0xc39d3, 0xc78ed, 0xc9e75, 0xcd0db, 0xcd81e, 0xd02e0, 0xd05c4, 0xd8f99, 0xd9359, 0xdff3b, 0xea623, - 0xf9100, 0xfc966 + 0xf9100, 0xfc966, ]; static V3: [u64; 42] = [ 0x14ca, 0x1e80, 0x587c, 0xa2d4, 0x14f6b, 0x1b100, 0x1b74c, 0x2477d, 0x29ba4, 0x33f25, 0x4c55f, 0x4d280, 0x50ffa, 0x53900, 0x5cf62, 0x63f66, 0x65623, 0x6fb19, 0x7a19e, 0x82eef, 0x83d2d, 0x88015, 0x8e6c5, 0x91086, 0x97429, 0x9aa27, 0xa01b7, 0xa304b, 0xafa06, 0xb1cb3, 0xbb9fc, 0xbf345, 0xc0761, 0xc0e78, 0xc5b99, 0xc9f09, 0xcc62c, 0xceb6e, 0xd98ad, 0xeecb3, - 0xef966, 0xfef9b + 0xef966, 0xfef9b, ]; // cuckoo28 at 50% edges of letter 'u' static V4: [u64; 42] = [ @@ -459,7 +453,7 @@ mod test { T: EdgeType, { let h = [0 as u8; 32]; - for n in [45 as u32, 49,131,143,151].iter() { + for n in [45 as u32, 49, 131, 143, 151].iter() { let mut cuckoo_ctx = CuckooContext::::new(16, 42, 10)?; cuckoo_ctx.set_header_nonce(h.to_vec(), Some(*n), false)?; let res = cuckoo_ctx.find_cycles()?; diff --git a/core/src/pow/types.rs b/core/src/pow/types.rs index 78f53b956..505957c5e 100644 --- a/core/src/pow/types.rs +++ b/core/src/pow/types.rs @@ -14,7 +14,7 @@ /// Types for a Cuck(at)oo proof of work and its encapsulation as a fully usable /// proof of work within a block header. -use std::cmp::{min,max}; +use std::cmp::{max, min}; use std::ops::{Add, Div, Mul, Sub}; use std::{fmt, iter}; @@ -36,11 +36,7 @@ where T: EdgeType, { /// Create new instance of context with appropriate parameters - fn new( - edge_bits: u8, - proof_size: usize, - max_sols: u32, - ) -> Result, Error>; + fn new(edge_bits: u8, proof_size: usize, max_sols: u32) -> Result, Error>; /// Sets the header along with an optional nonce at the end /// solve: whether to set up structures for a solve (true) or just validate (false) fn set_header_nonce( @@ -408,10 +404,7 @@ impl Readable for Proof { } nonces.push(nonce); } - Ok(Proof { - edge_bits, - nonces, - }) + Ok(Proof { edge_bits, nonces }) } } diff --git a/core/tests/consensus.rs b/core/tests/consensus.rs index 75f33d3cf..41f3d583f 100644 --- a/core/tests/consensus.rs +++ b/core/tests/consensus.rs @@ -123,7 +123,7 @@ fn get_diff_stats(chain_sim: &Vec) -> DiffStats { let earliest_block_height = tip_height as i64 - last_blocks.len() as i64; let earliest_ts = last_blocks[0].timestamp; - let latest_ts = last_blocks[last_blocks.len()-1].timestamp; + let latest_ts = last_blocks[last_blocks.len() - 1].timestamp; let mut i = 1; @@ -558,12 +558,12 @@ fn hard_forks() { assert!(valid_header_version(0, 1)); assert!(valid_header_version(10, 1)); assert!(!valid_header_version(10, 2)); - assert!(valid_header_version(YEAR_HEIGHT/2-1, 1)); + assert!(valid_header_version(YEAR_HEIGHT / 2 - 1, 1)); // v2 not active yet - assert!(!valid_header_version(YEAR_HEIGHT/2, 2)); - assert!(!valid_header_version(YEAR_HEIGHT/2, 1)); - assert!(!valid_header_version(YEAR_HEIGHT, 1)); - assert!(!valid_header_version(YEAR_HEIGHT/2+1, 2)); + assert!(!valid_header_version(YEAR_HEIGHT / 2, 2)); + assert!(!valid_header_version(YEAR_HEIGHT / 2, 1)); + assert!(!valid_header_version(YEAR_HEIGHT, 1)); + assert!(!valid_header_version(YEAR_HEIGHT / 2 + 1, 2)); } // #[test] diff --git a/keychain/src/extkey_bip32.rs b/keychain/src/extkey_bip32.rs index b02d1a9de..e6adc91c1 100644 --- a/keychain/src/extkey_bip32.rs +++ b/keychain/src/extkey_bip32.rs @@ -409,7 +409,8 @@ impl ExtendedPrivKey { hasher.append_sha512(&be_n); let result = hasher.result_sha512(); let mut sk = SecretKey::from_slice(secp, &result[..32]).map_err(Error::Ecdsa)?; - sk.add_assign(secp, &self.secret_key).map_err(Error::Ecdsa)?; + sk.add_assign(secp, &self.secret_key) + .map_err(Error::Ecdsa)?; Ok(ExtendedPrivKey { network: self.network, diff --git a/keychain/src/keychain.rs b/keychain/src/keychain.rs index 33f961d01..c3b73d2c8 100644 --- a/keychain/src/keychain.rs +++ b/keychain/src/keychain.rs @@ -85,8 +85,7 @@ impl Keychain for ExtKeychain { } else { None } - }) - .collect(); + }).collect(); let mut neg_keys: Vec = blind_sum .negative_key_ids @@ -98,8 +97,7 @@ impl Keychain for ExtKeychain { } else { None } - }) - .collect(); + }).collect(); pos_keys.extend( &blind_sum @@ -220,8 +218,7 @@ mod test { &BlindSum::new() .add_blinding_factor(BlindingFactor::from_secret_key(skey1)) .add_blinding_factor(BlindingFactor::from_secret_key(skey2)) - ) - .unwrap(), + ).unwrap(), BlindingFactor::from_secret_key(skey3), ); } diff --git a/servers/src/grin/seed.rs b/servers/src/grin/seed.rs index 0211fa787..b42cd52d6 100644 --- a/servers/src/grin/seed.rs +++ b/servers/src/grin/seed.rs @@ -31,7 +31,7 @@ use util::LOGGER; // DNS Seeds with contact email associated const DNS_SEEDS: &'static [&'static str] = &[ - "t4.seed.grin-tech.org", // igno.peverell@protonmail.com + "t4.seed.grin-tech.org", // igno.peverell@protonmail.com ]; pub fn connect_and_monitor( diff --git a/src/bin/tui/menu.rs b/src/bin/tui/menu.rs index 0da1f96ec..df07fdc7f 100644 --- a/src/bin/tui/menu.rs +++ b/src/bin/tui/menu.rs @@ -63,13 +63,11 @@ pub fn create() -> Box { let mut s: ViewRef> = c.find_id(MAIN_MENU).unwrap(); s.select_down(1)(c); Some(EventResult::Consumed(None)); - }) - .on_pre_event('k', move |c| { + }).on_pre_event('k', move |c| { let mut s: ViewRef> = c.find_id(MAIN_MENU).unwrap(); s.select_up(1)(c); Some(EventResult::Consumed(None)); - }) - .on_pre_event(Key::Tab, move |c| { + }).on_pre_event(Key::Tab, move |c| { let mut s: ViewRef> = c.find_id(MAIN_MENU).unwrap(); if s.selected_id().unwrap() == s.len() - 1 { s.set_selection(0)(c); diff --git a/wallet/src/file_wallet.rs b/wallet/src/file_wallet.rs index ddecb153a..41979ec00 100644 --- a/wallet/src/file_wallet.rs +++ b/wallet/src/file_wallet.rs @@ -444,9 +444,9 @@ where // write details file let mut details_file = File::create(details_file_path).context(ErrorKind::FileWallet(&"Could not create "))?; - let res_json = serde_json::to_string_pretty(&self.details).context(ErrorKind::FileWallet( - "Error serializing wallet details file", - ))?; + let res_json = serde_json::to_string_pretty(&self.details).context( + ErrorKind::FileWallet("Error serializing wallet details file"), + )?; details_file .write_all(res_json.into_bytes().as_slice()) .context(ErrorKind::FileWallet(&"Error writing wallet details file")) diff --git a/wallet/src/libwallet/controller.rs b/wallet/src/libwallet/controller.rs index 55852dd03..f3ce438b7 100644 --- a/wallet/src/libwallet/controller.rs +++ b/wallet/src/libwallet/controller.rs @@ -96,11 +96,11 @@ where let mut apis = ApiServer::new(); info!(LOGGER, "Starting HTTP Owner API server at {}.", addr); let socket_addr: SocketAddr = addr.parse().expect("unable to parse socket address"); - let api_thread = apis - .start(socket_addr, router, tls_config) - .context(ErrorKind::GenericError( - "API thread failed to start".to_string(), - ))?; + let api_thread = + apis.start(socket_addr, router, tls_config) + .context(ErrorKind::GenericError( + "API thread failed to start".to_string(), + ))?; api_thread .join() .map_err(|e| ErrorKind::GenericError(format!("API thread panicked :{:?}", e)).into()) @@ -128,11 +128,11 @@ where let mut apis = ApiServer::new(); info!(LOGGER, "Starting HTTP Foreign API server at {}.", addr); let socket_addr: SocketAddr = addr.parse().expect("unable to parse socket address"); - let api_thread = apis - .start(socket_addr, router, tls_config) - .context(ErrorKind::GenericError( - "API thread failed to start".to_string(), - ))?; + let api_thread = + apis.start(socket_addr, router, tls_config) + .context(ErrorKind::GenericError( + "API thread failed to start".to_string(), + ))?; api_thread .join() diff --git a/wallet/src/libwallet/error.rs b/wallet/src/libwallet/error.rs index 1d6e0c88b..d7dc888eb 100644 --- a/wallet/src/libwallet/error.rs +++ b/wallet/src/libwallet/error.rs @@ -34,7 +34,11 @@ pub struct Error { #[derive(Clone, Eq, PartialEq, Debug, Fail)] pub enum ErrorKind { /// Not enough funds - #[fail(display = "Not enough funds. Required: {}, Available: {}", needed, available)] + #[fail( + display = "Not enough funds. Required: {}, Available: {}", + needed, + available + )] NotEnoughFunds { /// available funds available: u64, @@ -43,7 +47,11 @@ pub enum ErrorKind { }, /// Fee dispute - #[fail(display = "Fee dispute: sender fee {}, recipient fee {}", sender_fee, recipient_fee)] + #[fail( + display = "Fee dispute: sender fee {}, recipient fee {}", + sender_fee, + recipient_fee + )] FeeDispute { /// sender fee sender_fee: u64, diff --git a/wallet/src/libwallet/internal/updater.rs b/wallet/src/libwallet/internal/updater.rs index 80d34462e..33c7c2796 100644 --- a/wallet/src/libwallet/internal/updater.rs +++ b/wallet/src/libwallet/internal/updater.rs @@ -55,8 +55,7 @@ where } else { out.status != OutputStatus::Spent } - }) - .collect::>(); + }).collect::>(); // only include outputs with a given tx_id if provided if let Some(id) = tx_id { @@ -73,8 +72,7 @@ where .map(|out| { let commit = wallet.get_commitment(&out.key_id).unwrap(); (out, commit) - }) - .collect(); + }).collect(); Ok(res) } diff --git a/wallet/src/lmdb_wallet.rs b/wallet/src/lmdb_wallet.rs index 16321fc14..ea1836174 100644 --- a/wallet/src/lmdb_wallet.rs +++ b/wallet/src/lmdb_wallet.rs @@ -409,7 +409,11 @@ where &mut parent_id.to_bytes().to_vec(), t.id as u64, ); - self.db.borrow().as_ref().unwrap().put_ser(&tx_log_key, &t)?; + self.db + .borrow() + .as_ref() + .unwrap() + .put_ser(&tx_log_key, &t)?; Ok(()) } diff --git a/wallet/tests/libwallet.rs b/wallet/tests/libwallet.rs index a2edfd8e3..9d1e19f3e 100644 --- a/wallet/tests/libwallet.rs +++ b/wallet/tests/libwallet.rs @@ -46,8 +46,7 @@ fn aggsig_sender_receiver_interaction() { &BlindSum::new() .sub_blinding_factor(BlindingFactor::from_secret_key(skey1)) .add_blinding_factor(BlindingFactor::from_secret_key(skey2)), - ) - .unwrap(); + ).unwrap(); keychain .secp() @@ -253,8 +252,7 @@ fn aggsig_sender_receiver_interaction_offset() { // subtract the kernel offset here like as would when // verifying a kernel signature .sub_blinding_factor(BlindingFactor::from_secret_key(kernel_offset)), - ) - .unwrap(); + ).unwrap(); keychain .secp() @@ -279,8 +277,7 @@ fn aggsig_sender_receiver_interaction_offset() { // subtract the kernel offset to create an aggsig context // with our "split" key .sub_blinding_factor(BlindingFactor::from_secret_key(kernel_offset)), - ) - .unwrap(); + ).unwrap(); let blind = blinding_factor.secret_key(&keychain.secp()).unwrap(); diff --git a/wallet/tests/transaction.rs b/wallet/tests/transaction.rs index 0b27d00a3..b780807f6 100644 --- a/wallet/tests/transaction.rs +++ b/wallet/tests/transaction.rs @@ -80,7 +80,7 @@ fn basic_transaction_api(test_dir: &str) -> Result<(), libwallet::Error> { // few values to keep things shorter let reward = core::consensus::REWARD; let cm = global::coinbase_maturity(); // assume all testing precedes soft fork height - // mine a few blocks + // mine a few blocks let _ = common::award_blocks_to_wallet(&chain, wallet1.clone(), 10); // Check wallet 1 contents are as expected @@ -325,7 +325,7 @@ fn tx_rollback(test_dir: &str) -> Result<(), libwallet::Error> { // few values to keep things shorter let reward = core::consensus::REWARD; let cm = global::coinbase_maturity(); // assume all testing precedes soft fork height - // mine a few blocks + // mine a few blocks let _ = common::award_blocks_to_wallet(&chain, wallet1.clone(), 5); let amount = 30_000_000_000;