[testnet2] Store output sum (#1043)

* block sums and reworked block validation
read and write block_sums
refactor validate on both block and txhashset
write block_sum on fast sync
we store the kernel_sum (need to account for the offset)

* block_sums

* rustfmt

* cleanup
This commit is contained in:
Antioch Peverell
2018-05-07 09:21:41 -04:00
committed by GitHub
parent b42b2a4f77
commit 4dd94ff39e
13 changed files with 426 additions and 141 deletions
+2 -4
View File
@@ -152,8 +152,8 @@ impl p2p::ChainAdapter for NetToChainAdapter {
.upgrade()
.expect("failed to upgrade weak ref to chain");
if let Ok(prev_header) = chain.get_block_header(&cb.header.previous) {
if let Ok(()) = block.validate(&prev_header) {
if let Ok(sums) = chain.get_block_sums(&cb.header.previous) {
if block.validate(&sums.output_sum, &sums.kernel_sum).is_ok() {
debug!(LOGGER, "adapter: successfully hydrated block from tx pool!");
self.process_block(block, addr)
} else {
@@ -351,7 +351,6 @@ impl p2p::ChainAdapter for NetToChainAdapter {
}
impl NetToChainAdapter {
/// Construct a new NetToChainAdapter instance
pub fn new(
currently_syncing: Arc<AtomicBool>,
@@ -599,7 +598,6 @@ impl ChainAdapter for ChainToPoolAndNetAdapter {
}
impl ChainToPoolAndNetAdapter {
/// Construct a ChainToPoolAndNetAdaper instance.
pub fn new(
tx_pool: Arc<RwLock<pool::TransactionPool<PoolToChainAdapter>>>,