Update bitflags to ^0.1 (#682)
* Removed unused crates * Add listconnectedpeers in grin client * Update bitflags to ^0.1 globally
This commit is contained in:
committed by
Ignotus Peverell
parent
1f7dd4eb73
commit
8a7eb94759
+2
-2
@@ -237,7 +237,7 @@ pub fn process_block(&self, b: Block, opts: Options)
|
||||
}
|
||||
|
||||
// notifying other parts of the system of the update
|
||||
if !opts.contains(SYNC) {
|
||||
if !opts.contains(Options::SYNC) {
|
||||
// broadcast the block
|
||||
let adapter = self.adapter.clone();
|
||||
adapter.block_accepted(&b, opts);
|
||||
@@ -254,7 +254,7 @@ pub fn process_block(&self, b: Block, opts: Options)
|
||||
// or less relevant blocks somehow.
|
||||
// We should also probably consider banning nodes that send us really old blocks.
|
||||
//
|
||||
if !opts.contains(SYNC) {
|
||||
if !opts.contains(Options::SYNC) {
|
||||
// broadcast the block
|
||||
let adapter = self.adapter.clone();
|
||||
adapter.block_accepted(&b, opts);
|
||||
|
||||
+1
-1
@@ -43,4 +43,4 @@ pub mod types;
|
||||
// Re-export the base interface
|
||||
|
||||
pub use chain::Chain;
|
||||
pub use types::{ChainAdapter, ChainStore, Error, Options, Tip, NONE, SKIP_POW, SYNC, MINE};
|
||||
pub use types::{ChainAdapter, ChainStore, Error, Options, Tip};
|
||||
|
||||
+3
-3
@@ -211,7 +211,7 @@ fn validate_header(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), E
|
||||
return Err(Error::InvalidBlockTime);
|
||||
}
|
||||
|
||||
if !ctx.opts.contains(SKIP_POW) {
|
||||
if !ctx.opts.contains(Options::SKIP_POW) {
|
||||
let n = global::sizeshift() as u32;
|
||||
if !(ctx.pow_verifier)(header, n) {
|
||||
error!(LOGGER, "pipe: validate_header failed for cuckoo shift size {}", n);
|
||||
@@ -242,7 +242,7 @@ fn validate_header(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), E
|
||||
return Err(Error::InvalidBlockTime);
|
||||
}
|
||||
|
||||
if !ctx.opts.contains(SKIP_POW) {
|
||||
if !ctx.opts.contains(Options::SKIP_POW) {
|
||||
// verify the proof of work and related parameters
|
||||
|
||||
// explicit check to ensure we are not below the minimum difficulty
|
||||
@@ -362,7 +362,7 @@ fn update_head(b: &Block, ctx: &mut BlockContext) -> Result<Option<Tip>, Error>
|
||||
// in sync mode, only update the "body chain", otherwise update both the
|
||||
// "header chain" and "body chain", updating the header chain in sync resets
|
||||
// all additional "future" headers we've received
|
||||
if ctx.opts.contains(SYNC) {
|
||||
if ctx.opts.contains(Options::SYNC) {
|
||||
ctx.store
|
||||
.save_body_head(&tip)
|
||||
.map_err(|e| Error::StoreErr(e, "pipe save body".to_owned()))?;
|
||||
|
||||
@@ -20,7 +20,7 @@ use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
use core::core::{Block, SumCommit, Input, Output, OutputIdentifier, TxKernel, COINBASE_OUTPUT};
|
||||
use core::core::{Block, SumCommit, Input, Output, OutputIdentifier, TxKernel, OutputFeatures};
|
||||
use core::core::pmmr::{HashSum, NoSum, Summable, PMMR};
|
||||
use core::core::hash::Hashed;
|
||||
use grin_store;
|
||||
@@ -134,7 +134,7 @@ impl SumTrees {
|
||||
// it claims to be spending, and that it is coinbase or non-coinbase.
|
||||
// If we are spending a coinbase output then go find the block
|
||||
// and check the coinbase maturity rule is being met.
|
||||
if input.features.contains(COINBASE_OUTPUT) {
|
||||
if input.features.contains(OutputFeatures::COINBASE_OUTPUT) {
|
||||
let block_hash = &input.out_block
|
||||
.expect("input spending coinbase output must have a block hash");
|
||||
let block = self.commit_index.get_block(&block_hash)?;
|
||||
@@ -280,7 +280,7 @@ impl<'a> Extension<'a> {
|
||||
// yet and it will be needed to calculate that hash. to work around this,
|
||||
// we insert coinbase outputs first to add at least one output of padding
|
||||
for out in &b.outputs {
|
||||
if out.features.contains(COINBASE_OUTPUT) {
|
||||
if out.features.contains(OutputFeatures::COINBASE_OUTPUT) {
|
||||
self.apply_output(out)?;
|
||||
}
|
||||
}
|
||||
@@ -293,7 +293,7 @@ impl<'a> Extension<'a> {
|
||||
|
||||
// now all regular, non coinbase outputs
|
||||
for out in &b.outputs {
|
||||
if !out.features.contains(COINBASE_OUTPUT) {
|
||||
if !out.features.contains(OutputFeatures::COINBASE_OUTPUT) {
|
||||
self.apply_output(out)?;
|
||||
}
|
||||
}
|
||||
@@ -336,7 +336,7 @@ impl<'a> Extension<'a> {
|
||||
// it claims to be spending, and it is coinbase or non-coinbase.
|
||||
// If we are spending a coinbase output then go find the block
|
||||
// and check the coinbase maturity rule is being met.
|
||||
if input.features.contains(COINBASE_OUTPUT) {
|
||||
if input.features.contains(OutputFeatures::COINBASE_OUTPUT) {
|
||||
let block_hash = &input.out_block
|
||||
.expect("input spending coinbase output must have a block hash");
|
||||
let block = self.commit_index.get_block(&block_hash)?;
|
||||
|
||||
+5
-5
@@ -27,15 +27,15 @@ use grin_store;
|
||||
|
||||
bitflags! {
|
||||
/// Options for block validation
|
||||
pub flags Options: u32 {
|
||||
pub struct Options: u32 {
|
||||
/// No flags
|
||||
const NONE = 0b00000000,
|
||||
const NONE = 0b00000000;
|
||||
/// Runs without checking the Proof of Work, mostly to make testing easier.
|
||||
const SKIP_POW = 0b00000001,
|
||||
const SKIP_POW = 0b00000001;
|
||||
/// Adds block while in syncing mode.
|
||||
const SYNC = 0b00000010,
|
||||
const SYNC = 0b00000010;
|
||||
/// Block validation on a block we mined ourselves
|
||||
const MINE = 0b00000100,
|
||||
const MINE = 0b00000100;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user