nakamoto
nakamoto copied to clipboard
Handle race condition with fast rescan and low gap limit
It's likely that a fast rescan combined with a normal or low gap limit will miss some blocks. The reason is that the rescan process doesn't pause when a block is matched, and it never backtracks; so if a block is matched at some height H, while the rescan process is at height H+100, and the matched block at H adds more than the gap-limit worth of new scripts, those will be missed between blocks H and H+100.
This was found out by @straylight-orbit