[SYNC PERFORMANCE] Adjust DifficultyIterator to no longer deserialize PoW proof nonces (#3671)

* replace bitvec with more efficient bitpack algorithm

* optimise proof_unpack_len

* move proof pack length calculation

* small refactor

* first pass attempt at not deserializing proof nonces in difficulty iter

* another 10 seconds gained by not deserialising the proof from the difficulty iterator

* add new deser parameters to tests where needed

* add skip_proof variants to store

* remove hash from difficulty iterator struct, rename HeaderInfo to HeaderDifficultyInfo

* replace bitvec with more efficient bitpack algorithm

* optimise proof_unpack_len

* move proof pack length calculation

* small refactor

* first pass attempt at not deserializing proof nonces in difficulty iter

* another 10 seconds gained by not deserialising the proof from the difficulty iterator

* add new deser parameters to tests where needed

* add skip_proof variants to store

* remove hash from difficulty iterator struct, rename HeaderInfo to HeaderDifficultyInfo
This commit is contained in:
Yeastplume
2021-12-10 11:39:39 +00:00
committed by GitHub
parent 7725a05ac1
commit 63c65605bb
20 changed files with 331 additions and 163 deletions
+1 -1
View File
@@ -277,7 +277,7 @@ impl OutputHandler {
.context(ErrorKind::Internal("cain error".to_owned()))?;
Ok(BlockOutputs {
header: BlockHeaderInfo::from_header(&header),
header: BlockHeaderDifficultyInfo::from_header(&header),
outputs: outputs,
})
}
+4 -3
View File
@@ -15,7 +15,7 @@
use super::utils::w;
use crate::core::core::hash::Hashed;
use crate::core::core::Transaction;
use crate::core::ser::{self, ProtocolVersion};
use crate::core::ser::{self, DeserializationMode, ProtocolVersion};
use crate::pool::{self, BlockChain, PoolAdapter, PoolEntry};
use crate::rest::*;
use crate::router::{Handler, ResponseFuture};
@@ -138,8 +138,9 @@ where
// All wallet api interaction explicitly uses protocol version 1 for now.
let version = ProtocolVersion(1);
let tx: Transaction = ser::deserialize(&mut &tx_bin[..], version)
.map_err(|e| ErrorKind::RequestError(format!("Bad request: {}", e)))?;
let tx: Transaction =
ser::deserialize(&mut &tx_bin[..], version, DeserializationMode::default())
.map_err(|e| ErrorKind::RequestError(format!("Bad request: {}", e)))?;
let source = pool::TxSource::PushApi;
info!(
+5 -5
View File
@@ -530,7 +530,7 @@ impl TxKernelPrintable {
// Just the information required for wallet reconstruction
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct BlockHeaderInfo {
pub struct BlockHeaderDifficultyInfo {
// Hash
pub hash: String,
/// Height of this block since the genesis block (height 0)
@@ -539,9 +539,9 @@ pub struct BlockHeaderInfo {
pub previous: String,
}
impl BlockHeaderInfo {
pub fn from_header(header: &core::BlockHeader) -> BlockHeaderInfo {
BlockHeaderInfo {
impl BlockHeaderDifficultyInfo {
pub fn from_header(header: &core::BlockHeader) -> BlockHeaderDifficultyInfo {
BlockHeaderDifficultyInfo {
hash: header.hash().to_hex(),
height: header.height,
previous: header.prev_hash.to_hex(),
@@ -705,7 +705,7 @@ impl CompactBlockPrintable {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct BlockOutputs {
/// The block header
pub header: BlockHeaderInfo,
pub header: BlockHeaderDifficultyInfo,
/// A printable version of the outputs
pub outputs: Vec<OutputPrintable>,
}