It calculates the three midstate hashes as soon as a CheckSig segwit operation happens, whathever the SigHash,
It is possible that two different threads calculate the midstate hashes of a transaction twice,
Befinits are:
hashcashes map access is limited so we don't have too much lock contention
Fewer conditional branches in consensus code
Simple to review
This commit is only for having a cache that is simple to review and understand. It is probably possible to fix the two first points above, but the code overhead is not worth it when our goal is only to fix the O(n²) issue.
Some notes about the implementation:
Befinits are:
This commit is only for having a cache that is simple to review and understand. It is probably possible to fix the two first points above, but the code overhead is not worth it when our goal is only to fix the O(n²) issue.
(rebased version of https://github.com/sipa/bitcoin/pull/70)