Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix/sync multiple tries #1864

Merged
merged 13 commits into from
Jun 5, 2020
16 changes: 4 additions & 12 deletions dataRetriever/requestHandlers/requestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,16 @@ func (rrh *resolverRequestHandler) requestByHashes(destShardID uint32, hashes []
}

rrh.whiteList.Add(unrequestedHashes)
err = rrh.requestHashesWithDataSplit(unrequestedHashes, txResolver)
if err != nil {
return
}

go rrh.requestHashesWithDataSplit(unrequestedHashes, txResolver)

rrh.addRequestedItems(unrequestedHashes)
}

func (rrh *resolverRequestHandler) requestHashesWithDataSplit(
unrequestedHashes [][]byte,
resolver HashSliceResolver,
) error {
) {
dataSplit := &partitioning.DataSplit{}
sliceBatches, err := dataSplit.SplitDataInChunks(unrequestedHashes, rrh.maxTxsToRequest)
if err != nil {
Expand All @@ -140,7 +138,6 @@ func (rrh *resolverRequestHandler) requestHashesWithDataSplit(
"num txs", len(unrequestedHashes),
"max txs to request", rrh.maxTxsToRequest,
)
return err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can call "return" here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would leave as it is - the next for could do nothing as is a range over a nil.

}

for _, batch := range sliceBatches {
Expand All @@ -153,8 +150,6 @@ func (rrh *resolverRequestHandler) requestHashesWithDataSplit(
)
}
}

return nil
}

// RequestUnsignedTransactions method asks for unsigned transactions from the connected peers
Expand Down Expand Up @@ -407,10 +402,7 @@ func (rrh *resolverRequestHandler) RequestTrieNodes(destShardID uint32, hashes [
log.Trace("requestByHashes", "hash", txHash)
}

err = rrh.requestHashesWithDataSplit(itemsToRequest, trieResolver)
if err != nil {
return
}
go rrh.requestHashesWithDataSplit(itemsToRequest, trieResolver)

rrh.addRequestedItems(itemsToRequest)
rrh.lastTrieRequestTime = time.Now()
Expand Down