network: fix requestBlocks() for (headers == blocks + 1)

In the very specific case when the list of headers received is exactly one
block ahead of the chain of full blocks requestBlocks() failed to generate
request to get the next full block.
This commit is contained in:
Roman Khimov 2019-09-26 20:18:17 +03:00
parent 3c40a53c4d
commit 9617a6f9e9

View file

@ -330,7 +330,7 @@ func (s *Server) requestBlocks(p Peer) error {
hashStart = s.chain.BlockHeight() + 1 hashStart = s.chain.BlockHeight() + 1
headerHeight = s.chain.HeaderHeight() headerHeight = s.chain.HeaderHeight()
) )
for hashStart < headerHeight && len(hashes) < maxBlockBatch { for hashStart <= headerHeight && len(hashes) < maxBlockBatch {
hash := s.chain.GetHeaderHash(int(hashStart)) hash := s.chain.GetHeaderHash(int(hashStart))
hashes = append(hashes, hash) hashes = append(hashes, hash)
hashStart++ hashStart++