Changes necessary to make wallet work pokt networks
This commit is contained in:
parent
94fea4725d
commit
5c3435c12f
|
@ -19,8 +19,10 @@ var (
|
|||
// archival request.
|
||||
binanceChainMaxInitialRange = big.NewInt(500000)
|
||||
binanceChainErc20BatchSize = big.NewInt(5000)
|
||||
erc20BatchSize = big.NewInt(100000)
|
||||
goerliErc20BatchSize = big.NewInt(100000)
|
||||
erc20BatchSize = big.NewInt(500000)
|
||||
binancChainID = uint64(56)
|
||||
goerliChainID = uint64(5)
|
||||
binanceTestChainID = uint64(97)
|
||||
numberOfBlocksCheckedPerIteration = 40
|
||||
)
|
||||
|
@ -101,6 +103,10 @@ func getErc20BatchSize(chainID uint64) *big.Int {
|
|||
return binanceChainErc20BatchSize
|
||||
}
|
||||
|
||||
if chainID == goerliChainID {
|
||||
return goerliErc20BatchSize
|
||||
}
|
||||
|
||||
return erc20BatchSize
|
||||
}
|
||||
|
||||
|
@ -109,7 +115,7 @@ func (c *erc20HistoricalCommand) Run(ctx context.Context) (err error) {
|
|||
if c.iterator == nil {
|
||||
c.iterator, err = SetupIterativeDownloader(
|
||||
c.db, c.chainClient, c.address,
|
||||
c.erc20, getErc20BatchSize(c.chainClient.ChainID), c.to, c.from, !isBinanceChain(c.chainClient.ChainID))
|
||||
c.erc20, getErc20BatchSize(c.chainClient.ChainID), c.to, c.from)
|
||||
if err != nil {
|
||||
log.Error("failed to setup historical downloader for erc20")
|
||||
return err
|
||||
|
|
|
@ -12,16 +12,12 @@ import (
|
|||
// SetupIterativeDownloader configures IterativeDownloader with last known synced block.
|
||||
func SetupIterativeDownloader(
|
||||
db *Database, client HeaderReader, address common.Address,
|
||||
downloader BatchDownloader, size *big.Int, to *big.Int, from *big.Int, isBatchSizeAdjustable bool) (*IterativeDownloader, error) {
|
||||
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 isBatchSizeAdjustable && adjustedSize.Cmp(size) == 1 {
|
||||
size = adjustedSize
|
||||
}
|
||||
log.Info("iterative downloader", "address", address, "from", from, "to", to, "size", size)
|
||||
d := &IterativeDownloader{
|
||||
client: client,
|
||||
|
@ -68,7 +64,7 @@ func (d *IterativeDownloader) Next(parent context.Context) ([]*DBHeader, *big.In
|
|||
if from.Cmp(d.from) == -1 {
|
||||
from = d.from
|
||||
}
|
||||
log.Info("load erc20 transfers in range", "from", from, "to", to)
|
||||
log.Info("load erc20 transfers in range", "from", from, "to", to, "batchSize", d.batchSize)
|
||||
headers, err := d.downloader.GetHeadersInRange(parent, from, to)
|
||||
if err != nil {
|
||||
log.Error("failed to get transfer in between two bloks", "from", from, "to", to, "error", err)
|
||||
|
|
Loading…
Reference in New Issue