bitcoin-iterate
bitcoin-iterate copied to clipboard
Replace openssl/sha2 with a sha256 implementation
This is to remove openssl as a dependency, making this tool entirely free standing the sha256 implementation is from libsecp256k1(https://github.com/bitcoin-core/secp256k1/blob/master/src/hash_impl.h) but I've adjusted it to the code style here.
There are no tests here, but I manually sampled a few transactions and blocks and verified that their hash matches what's in blockstream.info
There doesn't seem to be any performance difference as most of the work is in I/O:
Before:
$ time ./bitcoin-iterate -q && time ./bitcoin-iterate -q
bitcoin-iterate: Skipped 4681563 at end of /home/elichai2/.bitcoin/blocks/blk02222.dat
real 2m30.215s
user 0m1.315s
sys 0m13.255s
bitcoin-iterate: Skipped 4681563 at end of /home/elichai2/.bitcoin/blocks/blk02222.dat
real 2m28.074s
user 0m1.322s
sys 0m13.238s
After:
$ time ./bitcoin-iterate -q && time ./bitcoin-iterate -q
bitcoin-iterate: Skipped 4681563 at end of /home/elichai2/.bitcoin/blocks/blk02222.dat
real 2m30.056s
user 0m1.401s
sys 0m13.151s
bitcoin-iterate: Skipped 4681563 at end of /home/elichai2/.bitcoin/blocks/blk02222.dat
real 2m26.071s
user 0m1.467s
sys 0m13.074s
This should resolve #16 and resolve #11
this looks good to me but of course this is for @rustyrussell to decide. Did not expect that my issue would actually get a PR or any fix at all. Kind of only put it there if beginners use the code and google the error.
It took me 5-10 minutes of work, so why not, And it's obviously fine if @rustyrussell decides to leave this as is (it still works great even after years)
Tested ACK 9ddef39a937ebe81cfdf9dbd4ace766b9d2c43f0 (processed all testnet3 blocks)