Optimize locator construction for "getblocks" messages
Optimize locator construction for "getblocks" messages

This caches the block locators used to ask for a range of blocks. Due to a
sub-optimal workaround in our old net messaging code, a node will ask each
peer that advertises a block for the next range. The node generates a sub-
set of hashes from the current block chain used as a locator for the block
in the chain of the peer. Creating locators is extremely expensive--a node
needs to scan the entire chain--so we cache the locators and reuse them if
the node sends the same request. For nodes with many connections, this can
dramatically improve the performance of the messaging system when it needs
to respond to new blocks.

This optimization will become unnecessary when we backport newer chain and
net messaging code from Bitcoin. For now, this cache can greatly improve a
node's ability to serve a higher number of connections.

caraka/gridcoinresearch,gridcoin/Gridcoin-Research,gridcoin/Gridcoin-Research,gridcoin/Gridcoin-Research,caraka/gridcoinresearch,Git-Jiro/Gridcoin-Research,gridcoin/Gridcoin-Research,Git-Jiro/Gridcoin-Research,caraka/gridcoinresearch,caraka/gridcoinresearch,Git-Jiro/Gridcoin-Research,gridcoin/Gridcoin-Research,caraka/gridcoinresearch,Git-Jiro/Gridcoin-Research,Git-Jiro/Gridcoin-Research,gridcoin/Gridcoin-Research,caraka/gridcoinresearch