samourai-wallet-android icon indicating copy to clipboard operation
samourai-wallet-android copied to clipboard

Speed up PoW verification hashing

Open reardencode opened this issue 7 years ago • 4 comments

In a microbenchmark, this method of reversing hex bytes is an order of magnitude faster. (100 nanoseconds vs. 1 microsecond for 10 bytes on an Intel Core i7-5600U)

reardencode avatar May 14 '18 15:05 reardencode

There's Utils.reverseBytes() in bitcoinj. Can get rid of the member function altogether.

SamouraiDev avatar May 14 '18 15:05 SamouraiDev

Utils.reverseBytes is just for byte[], actually not sure why it exists since there's Arrays.reverse that is used later in calcHash. This method could also be modified to build up a byte[] instead of first building a String and then decoding it (I'm happy to do that if its your preference).

reardencode avatar May 14 '18 15:05 reardencode

The use of String is mainly due to reading in from JSON and then logging for debug purposes. Better to keep them around for now.

SamouraiDev avatar May 14 '18 15:05 SamouraiDev

That was my thinking too.

reardencode avatar May 14 '18 15:05 reardencode