diff options
| author | Matt Corallo <[email protected]> | 2017-04-27 11:31:53 -0400 |
|---|---|---|
| committer | Matt Corallo <[email protected]> | 2017-12-04 09:39:21 -0500 |
| commit | 22fdddeabb17881af2004c45538f91514837d363 (patch) | |
| tree | 0434b725bfdf14daffab46b620008d0c3cf82eb6 /src | |
| parent | Move some additional variables into CChainState private (diff) | |
| download | discoin-22fdddeabb17881af2004c45538f91514837d363.tar.xz discoin-22fdddeabb17881af2004c45538f91514837d363.zip | |
Avoid calling GetSerializeSize on each tx in a block if !fTxIndex
Diffstat (limited to 'src')
| -rw-r--r-- | src/validation.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index f6b77b6c3..af303df73 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1647,6 +1647,8 @@ static bool WriteUndoDataForBlock(const CBlockUndo& blockundo, CValidationState& static bool WriteTxIndexDataForBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex) { + if (!fTxIndex) return true; + CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size())); std::vector<std::pair<uint256, CDiskTxPos> > vPos; vPos.reserve(block.vtx.size()); @@ -1656,9 +1658,9 @@ static bool WriteTxIndexDataForBlock(const CBlock& block, CValidationState& stat pos.nTxOffset += ::GetSerializeSize(*tx, SER_DISK, CLIENT_VERSION); } - if (fTxIndex) - if (!pblocktree->WriteTxIndex(vPos)) - return AbortNode(state, "Failed to write transaction index"); + if (!pblocktree->WriteTxIndex(vPos)) { + return AbortNode(state, "Failed to write transaction index"); + } return true; } |