When serving historic blocks, there is no need to calculate the hash of each transaction, so just skip it.
This is mostly refactoring with the following changes:
- Introduce a
CPureTransaction
, a stripped down version ofCTransaction
(nohash
orGetHash()
members). Then deriveclass CTransaction
fromCPureTransaction
- Deduce a
CPureBlock
which referencesCPureTransactions
in itsvtx
.
Deserialization now only takes 14% of the wall clock time it took previously on my machine. You can check locally with:
0./bench_bitcoin --filter=DeserializeBlockTest && ./bench_bitcoin --filter=DeserializePureBlockTest
Sending a single historic block now takes slightly less (90% of the wall clock time it took previously) on a local network. I presume the speedup is more pronounced when sending more than one block.