mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
rustfmt
This commit is contained in:
parent
f058b14aea
commit
e7c380836b
20 changed files with 54 additions and 55 deletions
|
@ -19,7 +19,6 @@ extern crate grin_pool as pool;
|
|||
extern crate grin_store as store;
|
||||
extern crate grin_util as util;
|
||||
|
||||
|
||||
extern crate failure;
|
||||
#[macro_use]
|
||||
extern crate failure_derive;
|
||||
|
@ -45,5 +44,5 @@ mod rest;
|
|||
mod types;
|
||||
|
||||
pub use handlers::start_rest_apis;
|
||||
pub use types::*;
|
||||
pub use rest::*;
|
||||
pub use types::*;
|
||||
|
|
|
@ -25,8 +25,7 @@ use lmdb;
|
|||
use core::core::hash::{Hash, Hashed};
|
||||
use core::core::merkle_proof::MerkleProof;
|
||||
use core::core::target::Difficulty;
|
||||
use core::core::{Block, BlockHeader, Output, OutputIdentifier, Transaction,
|
||||
TxKernel};
|
||||
use core::core::{Block, BlockHeader, Output, OutputIdentifier, Transaction, TxKernel};
|
||||
use core::global;
|
||||
use grin_store::Error::NotFoundErr;
|
||||
use pipe;
|
||||
|
@ -436,25 +435,25 @@ impl Chain {
|
|||
})
|
||||
}
|
||||
|
||||
/// Sets the txhashset roots on a brand new block by applying the block on
|
||||
/// the current txhashset state.
|
||||
pub fn set_txhashset_roots(&self, b: &mut Block, is_fork: bool) -> Result<(), Error> {
|
||||
let mut txhashset = self.txhashset.write().unwrap();
|
||||
let store = self.store.clone();
|
||||
/// Sets the txhashset roots on a brand new block by applying the block on
|
||||
/// the current txhashset state.
|
||||
pub fn set_txhashset_roots(&self, b: &mut Block, is_fork: bool) -> Result<(), Error> {
|
||||
let mut txhashset = self.txhashset.write().unwrap();
|
||||
let store = self.store.clone();
|
||||
|
||||
let roots = txhashset::extending_readonly(&mut txhashset, |extension| {
|
||||
if is_fork {
|
||||
pipe::rewind_and_apply_fork(b, store, extension)?;
|
||||
}
|
||||
extension.apply_block(b)?;
|
||||
Ok(extension.roots())
|
||||
})?;
|
||||
let roots = txhashset::extending_readonly(&mut txhashset, |extension| {
|
||||
if is_fork {
|
||||
pipe::rewind_and_apply_fork(b, store, extension)?;
|
||||
}
|
||||
extension.apply_block(b)?;
|
||||
Ok(extension.roots())
|
||||
})?;
|
||||
|
||||
b.header.output_root = roots.output_root;
|
||||
b.header.range_proof_root = roots.rproof_root;
|
||||
b.header.kernel_root = roots.kernel_root;
|
||||
Ok(())
|
||||
}
|
||||
b.header.output_root = roots.output_root;
|
||||
b.header.range_proof_root = roots.rproof_root;
|
||||
b.header.kernel_root = roots.kernel_root;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Return a pre-built Merkle proof for the given commitment from the store.
|
||||
pub fn get_merkle_proof(
|
||||
|
@ -826,7 +825,6 @@ fn setup_head(
|
|||
// to match the provided block header.
|
||||
let header = store.get_block_header(&head.last_block_h)?;
|
||||
|
||||
|
||||
let res = txhashset::extending(txhashset, &mut batch, |extension| {
|
||||
extension.rewind(&header, &head_header, true, true, true)?;
|
||||
extension.validate_roots(&header)?;
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
extern crate byteorder;
|
||||
extern crate lmdb_zero as lmdb;
|
||||
extern crate croaring;
|
||||
extern crate lmdb_zero as lmdb;
|
||||
extern crate lru_cache;
|
||||
extern crate serde;
|
||||
#[macro_use]
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use lmdb;
|
||||
use croaring::Bitmap;
|
||||
use lmdb;
|
||||
use lru_cache::LruCache;
|
||||
|
||||
use util::secp::pedersen::Commitment;
|
||||
|
|
|
@ -458,7 +458,15 @@ impl<'a> Extension<'a> {
|
|||
let rewind_add_pos: Bitmap = ((output_pos + 1)..(latest_output_pos + 1))
|
||||
.map(|x| x as u32)
|
||||
.collect();
|
||||
self.rewind_to_pos(output_pos, kernel_pos, &rewind_add_pos, rewind_rm_pos, true, true, true)?;
|
||||
self.rewind_to_pos(
|
||||
output_pos,
|
||||
kernel_pos,
|
||||
&rewind_add_pos,
|
||||
rewind_rm_pos,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -483,7 +491,8 @@ impl<'a> Extension<'a> {
|
|||
// Build bitmap of output pos spent (as inputs) by this tx for rewind.
|
||||
let rewind_rm_pos = tx.inputs
|
||||
.iter()
|
||||
.filter_map(|x| self.get_output_pos(&x.commitment()).ok()) .map(|x| x as u32)
|
||||
.filter_map(|x| self.get_output_pos(&x.commitment()).ok())
|
||||
.map(|x| x as u32)
|
||||
.collect();
|
||||
|
||||
for ref output in &tx.outputs {
|
||||
|
@ -792,7 +801,7 @@ impl<'a> Extension<'a> {
|
|||
&rewind_rm_pos,
|
||||
rewind_utxo,
|
||||
rewind_kernel,
|
||||
rewind_rangeproof
|
||||
rewind_rangeproof,
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
|
@ -916,10 +925,8 @@ impl<'a> Extension<'a> {
|
|||
// The real magicking happens here.
|
||||
// Sum of kernel excesses should equal sum of
|
||||
// unspent outputs minus total supply.
|
||||
let (output_sum, kernel_sum) = self.verify_kernel_sums(
|
||||
header.total_overage(),
|
||||
header.total_kernel_offset(),
|
||||
)?;
|
||||
let (output_sum, kernel_sum) =
|
||||
self.verify_kernel_sums(header.total_overage(), header.total_kernel_offset())?;
|
||||
|
||||
// This is an expensive verification step.
|
||||
self.verify_kernel_signatures()?;
|
||||
|
|
|
@ -346,6 +346,3 @@ impl Default for BlockSums {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ extern crate grin_core;
|
|||
#[macro_use]
|
||||
extern crate libfuzzer_sys;
|
||||
|
||||
use grin_core::ser;
|
||||
use grin_core::core::block;
|
||||
use grin_core::ser;
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
let mut d = data.clone();
|
||||
|
|
|
@ -3,8 +3,8 @@ extern crate grin_core;
|
|||
#[macro_use]
|
||||
extern crate libfuzzer_sys;
|
||||
|
||||
use grin_core::ser;
|
||||
use grin_core::core::block;
|
||||
use grin_core::ser;
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
let mut d = data.clone();
|
||||
|
|
|
@ -3,8 +3,8 @@ extern crate grin_core;
|
|||
#[macro_use]
|
||||
extern crate libfuzzer_sys;
|
||||
|
||||
use grin_core::ser;
|
||||
use grin_core::core::transaction;
|
||||
use grin_core::ser;
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
let mut d = data.clone();
|
||||
|
|
|
@ -702,7 +702,8 @@ impl Block {
|
|||
vec![prev_kernel_offset.clone()],
|
||||
)?
|
||||
};
|
||||
let (_utxo_sum, kernel_sum) = self.verify_kernel_sums(self.header.overage(), block_kernel_offset)?;
|
||||
let (_utxo_sum, kernel_sum) =
|
||||
self.verify_kernel_sums(self.header.overage(), block_kernel_offset)?;
|
||||
|
||||
// check the block header's total kernel sum
|
||||
let total_sum = committed::sum_commits(vec![kernel_sum, prev_kernel_sum.clone()], vec![])?;
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
use time;
|
||||
|
||||
use core;
|
||||
use consensus;
|
||||
use core;
|
||||
use core::target::Difficulty;
|
||||
use global;
|
||||
|
||||
|
|
|
@ -14,6 +14,6 @@
|
|||
|
||||
//! Mining + Mining server
|
||||
|
||||
pub mod test_miner;
|
||||
pub mod stratumserver;
|
||||
mod mine_block;
|
||||
pub mod stratumserver;
|
||||
pub mod test_miner;
|
||||
|
|
|
@ -40,8 +40,8 @@ pub mod tui;
|
|||
|
||||
use std::env::current_dir;
|
||||
use std::process::exit;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
//! Grin TUI
|
||||
extern crate chrono;
|
||||
|
||||
pub mod ui;
|
||||
pub mod table;
|
||||
mod peers;
|
||||
mod constants;
|
||||
mod menu;
|
||||
mod status;
|
||||
mod mining;
|
||||
mod version;
|
||||
mod peers;
|
||||
mod status;
|
||||
pub mod table;
|
||||
mod types;
|
||||
pub mod ui;
|
||||
mod version;
|
||||
|
|
|
@ -34,8 +34,8 @@ extern crate slog;
|
|||
extern crate grin_core as core;
|
||||
extern crate grin_util as util;
|
||||
|
||||
mod lmdb;
|
||||
pub mod leaf_set;
|
||||
mod lmdb;
|
||||
pub mod pmmr;
|
||||
pub mod rm_log;
|
||||
pub mod types;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
/// to bytes. Given that rustc-serialize is deprecated and serde doesn't
|
||||
/// provide easy hex encoding, hex is a bit in limbo right now in Rust-
|
||||
/// land. It's simple enough that we can just have our own.
|
||||
|
||||
use std::fmt::Write;
|
||||
use std::num;
|
||||
|
||||
|
|
|
@ -54,10 +54,10 @@ pub mod types;
|
|||
pub use types::{LogLevel, LoggingConfig};
|
||||
|
||||
// other utils
|
||||
use byteorder::{BigEndian, ByteOrder};
|
||||
use std::cell::{Ref, RefCell};
|
||||
#[allow(unused_imports)]
|
||||
use std::ops::Deref;
|
||||
use byteorder::{BigEndian, ByteOrder};
|
||||
|
||||
mod hex;
|
||||
pub use hex::*;
|
||||
|
|
|
@ -12,12 +12,11 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::fs::{self, File};
|
||||
/// Wrappers around the `zip-rs` library to compress and decompress zip
|
||||
/// bzip2 archives.
|
||||
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
use std::fs::{self, File};
|
||||
use walkdir::WalkDir;
|
||||
|
||||
use zip_rs;
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
extern crate grin_util as util;
|
||||
|
||||
use std::fs::{self, File};
|
||||
use std::path::Path;
|
||||
use std::io::{self, Write};
|
||||
use std::path::Path;
|
||||
use util::zip;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -163,8 +163,7 @@ where
|
|||
debug!(LOGGER, "selected some coins - {}", coins.len());
|
||||
|
||||
let fee = tx_fee(coins.len(), 2, selection::coins_proof_count(&coins), None);
|
||||
let (mut parts, _, _) =
|
||||
selection::inputs_and_change(&coins, wallet, amount, fee)?;
|
||||
let (mut parts, _, _) = selection::inputs_and_change(&coins, wallet, amount, fee)?;
|
||||
|
||||
//TODO: If we end up using this, create change output here
|
||||
|
||||
|
|
Loading…
Reference in a new issue