[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:
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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
@@ -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>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user