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