Sync bug fixes
Created by: VoidingWarranties
This PR fixes 2 major and 1 minor bugs.
Major bugs:
- SendBlocks was sending the entire blockchain every time (tested in
TestRPCSendBlockSendsOnlyNecessaryBlocks
) - SendBlocks would sometimes fail to send the last block (tested in
TestRPCSendBlocks
)
Minor bug:
- blockHistory included the genesis block twice sometimes (when height == step). This doesn't cause any problems, but no reason to not fix it. Even with this fix the genesis block is still included twice (once at blockHistory[0] and once at blockHistory[31]) if the only block is the genesis block, which should only happen during initial blockchain download.
This should dramatically improve syncing performance.