Branch: refs/heads/master
Home: https://github.com/conformal/btcd
Commit: de31674a8dabe82af8f8524e330d142ffcd572fa
https://github.com/conformal/btcd/commit/de31674a8dabe82af8f8524e330d142ffcd572fa
Author: Josh Rickmar <[email protected]>
Date: 2014-03-21 (Fri, 21 Mar 2014)
Changed paths:
M rpcwebsocket.go
Log Message:
-----------
Optimize rescan.
This change adds rescan fast paths for all current implementations of
the btcutil.Address interface. Rather than encoding a payment address
string from a txout script, the minimum number of bytes (which depends
on the address type) are copied into a stack array and used as a
lookup key to a map exclusive for that address type. This performs
better than the previous implementation due to avoiding the base58
encoding and generating less garbage (so each GC cycle completes
faster).
If the address type switch falls into the default (unhandled) case,
the encoded payment address is used as a fallback. This keeps the
intended rescan behavior even when new implementations of
btcutil.Address are added without a rescan fast path.
Benchmarks indicate that when a fast path is followed, for 20 byte
RIPEMD-160 hashes (such as P2PKH and P2SH), skipping the payment
address encoding (and thus bypassing the base58 encoding code) can
result in map lookups up to 60x faster.