Refactor rewind single header (#1390)
* refactor txhashset to only take a single header no need to pass in current head_header each time * rustfmt * fix bug introduced in rewind with LMDB * rustfmt * add some comments
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
extern crate chrono;
|
||||
extern crate env_logger;
|
||||
extern crate grin_chain as chain;
|
||||
extern crate grin_core as core;
|
||||
@@ -20,14 +21,13 @@ extern crate grin_store as store;
|
||||
extern crate grin_util as util;
|
||||
extern crate grin_wallet as wallet;
|
||||
extern crate rand;
|
||||
extern crate chrono;
|
||||
|
||||
use chrono::Duration;
|
||||
use std::fs;
|
||||
use std::sync::Arc;
|
||||
use chrono::Duration;
|
||||
|
||||
use chain::Chain;
|
||||
use chain::types::{NoopAdapter, Tip};
|
||||
use chain::Chain;
|
||||
use core::core::target::Difficulty;
|
||||
use core::core::{Block, BlockHeader, Transaction};
|
||||
use core::global::{self, ChainTypes};
|
||||
@@ -96,8 +96,6 @@ fn data_files() {
|
||||
.process_block(b.clone(), chain::Options::MINE)
|
||||
.unwrap();
|
||||
|
||||
let head = Tip::from_block(&b.header);
|
||||
|
||||
chain.validate(false).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +242,6 @@ fn spend_in_fork_and_compact() {
|
||||
// mine the first block and keep track of the block_hash
|
||||
// so we can spend the coinbase later
|
||||
let b = prepare_block(&kc, &fork_head, &chain, 2);
|
||||
let block_hash = b.hash();
|
||||
let out_id = OutputIdentifier::from_output(&b.outputs()[0]);
|
||||
assert!(out_id.features.contains(OutputFeatures::COINBASE_OUTPUT));
|
||||
fork_head = b.header.clone();
|
||||
@@ -250,8 +249,6 @@ fn spend_in_fork_and_compact() {
|
||||
.process_block(b.clone(), chain::Options::SKIP_POW)
|
||||
.unwrap();
|
||||
|
||||
let merkle_proof = chain.get_merkle_proof(&out_id, &b.header).unwrap();
|
||||
|
||||
// now mine three further blocks
|
||||
for n in 3..6 {
|
||||
let b = prepare_block(&kc, &fork_head, &chain, n);
|
||||
|
||||
@@ -23,7 +23,7 @@ extern crate rand;
|
||||
use std::fs;
|
||||
use std::sync::Arc;
|
||||
|
||||
use chain::{ChainStore, Tip};
|
||||
use chain::Tip;
|
||||
use core::core::hash::Hashed;
|
||||
use core::core::target::Difficulty;
|
||||
use core::core::{Block, BlockHeader};
|
||||
|
||||
@@ -26,7 +26,7 @@ use std::fs;
|
||||
use std::sync::Arc;
|
||||
|
||||
use chain::types::NoopAdapter;
|
||||
use chain::{Error, ErrorKind};
|
||||
use chain::ErrorKind;
|
||||
use core::core::target::Difficulty;
|
||||
use core::core::{transaction, OutputIdentifier};
|
||||
use core::global::{self, ChainTypes};
|
||||
@@ -86,17 +86,10 @@ fn test_coinbase_maturity() {
|
||||
.contains(transaction::OutputFeatures::COINBASE_OUTPUT)
|
||||
);
|
||||
|
||||
let out_id = OutputIdentifier::from_output(&coinbase_output);
|
||||
|
||||
// we will need this later when we want to spend the coinbase output
|
||||
let block_hash = block.hash();
|
||||
|
||||
chain
|
||||
.process_block(block.clone(), chain::Options::MINE)
|
||||
.unwrap();
|
||||
|
||||
let merkle_proof = chain.get_merkle_proof(&out_id, &block.header).unwrap();
|
||||
|
||||
let prev = chain.head_header().unwrap();
|
||||
|
||||
let amount = consensus::REWARD;
|
||||
|
||||
Reference in New Issue
Block a user