Dont crash if to or from are nil

This commit is contained in:
Andrea Maria Piana 2020-11-18 10:16:51 +01:00
parent 70414c90b9
commit 9814a9a5e7
2 changed files with 7 additions and 1 deletions

View File

@ -1 +1 @@
0.63.10
0.63.11

View File

@ -2,6 +2,7 @@ package wallet
import (
"context"
"errors"
"math/big"
"time"
@ -13,6 +14,11 @@ import (
func SetupIterativeDownloader(
db *Database, client HeaderReader, address common.Address,
downloader BatchDownloader, size *big.Int, to *big.Int, from *big.Int) (*IterativeDownloader, error) {
if to == nil || from == nil {
return nil, errors.New("to or from cannot be nil")
}
adjustedSize := big.NewInt(0).Div(big.NewInt(0).Sub(to, from), big.NewInt(10))
if adjustedSize.Cmp(size) == 1 {
size = adjustedSize