Fixed lint errors from gosimple linter (#4900)

This commit is contained in:
Leonard Chinonso 2022-08-02 15:09:00 +01:00 committed by GitHub
parent 808df67683
commit 8774e1d8a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 36 deletions

View File

@ -21,13 +21,11 @@ func (api *APIImpl) NewPendingTransactionFilter(_ context.Context) (string, erro
id := api.filters.SubscribePendingTxs(txsCh)
go func() {
for {
select {
case txs, ok := <-txsCh:
if !ok {
return
}
api.filters.AddPendingTxs(id, txs)
txs, ok := <-txsCh
if !ok {
return
}
api.filters.AddPendingTxs(id, txs)
}
}()
return "0x" + string(id), nil
@ -42,13 +40,11 @@ func (api *APIImpl) NewBlockFilter(_ context.Context) (string, error) {
id := api.filters.SubscribeNewHeads(ch)
go func() {
for {
select {
case block, ok := <-ch:
if !ok {
return
}
api.filters.AddPendingBlock(id, block)
block, ok := <-ch
if !ok {
return
}
api.filters.AddPendingBlock(id, block)
}
}()
return "0x" + string(id), nil
@ -63,13 +59,11 @@ func (api *APIImpl) NewFilter(_ context.Context, crit filters.FilterCriteria) (s
id := api.filters.SubscribeLogs(logs, crit)
go func() {
for {
select {
case lg, ok := <-logs:
if !ok {
return
}
api.filters.AddLogs(id, lg)
lg, ok := <-logs
if !ok {
return
}
api.filters.AddLogs(id, lg)
}
}()
return hexutil.EncodeUint64(uint64(id)), nil

View File

@ -324,8 +324,7 @@ func Erigon22(genesis *core.Genesis, logger log.Logger) error {
}
startTime := time.Now()
var blockReader services.FullBlockReader
var allSnapshots *snapshotsync.RoSnapshots
allSnapshots = snapshotsync.NewRoSnapshots(ethconfig.NewSnapCfg(true, false, true), path.Join(datadir, "snapshots"))
var allSnapshots = snapshotsync.NewRoSnapshots(ethconfig.NewSnapCfg(true, false, true), path.Join(datadir, "snapshots"))
defer allSnapshots.Close()
if err := allSnapshots.ReopenFolder(); err != nil {
return fmt.Errorf("reopen snapshot segments: %w", err)

View File

@ -155,8 +155,7 @@ func Erigon23(genesis *core.Genesis, chainConfig *params.ChainConfig, logger log
}()
var blockReader services.FullBlockReader
var allSnapshots *snapshotsync.RoSnapshots
allSnapshots = snapshotsync.NewRoSnapshots(ethconfig.NewSnapCfg(true, false, true), path.Join(datadir, "snapshots"))
var allSnapshots = snapshotsync.NewRoSnapshots(ethconfig.NewSnapCfg(true, false, true), path.Join(datadir, "snapshots"))
defer allSnapshots.Close()
if err := allSnapshots.ReopenFolder(); err != nil {
return fmt.Errorf("reopen snapshot segments: %w", err)

View File

@ -41,8 +41,7 @@ var replayTxCmd = &cobra.Command{
func ReplayTx(genesis *core.Genesis) error {
var blockReader services.FullBlockReader
var allSnapshots *snapshotsync.RoSnapshots
allSnapshots = snapshotsync.NewRoSnapshots(ethconfig.NewSnapCfg(true, true, true), path.Join(datadir, "snapshots"))
var allSnapshots = snapshotsync.NewRoSnapshots(ethconfig.NewSnapCfg(true, true, true), path.Join(datadir, "snapshots"))
defer allSnapshots.Close()
if err := allSnapshots.ReopenFolder(); err != nil {
return fmt.Errorf("reopen snapshot segments: %w", err)

View File

@ -477,8 +477,7 @@ func Recon(genesis *core.Genesis, logger log.Logger) error {
go fillWorkers[i].bitmapAccounts()
}
for atomic.LoadUint64(&doneCount) < uint64(workerCount) {
select {
case <-logEvery.C:
for range logEvery.C {
var m runtime.MemStats
libcommon.ReadMemStats(&m)
var p float64
@ -499,8 +498,7 @@ func Recon(genesis *core.Genesis, logger log.Logger) error {
go fillWorkers[i].bitmapStorage()
}
for atomic.LoadUint64(&doneCount) < uint64(workerCount) {
select {
case <-logEvery.C:
for range logEvery.C {
var m runtime.MemStats
libcommon.ReadMemStats(&m)
var p float64
@ -521,8 +519,7 @@ func Recon(genesis *core.Genesis, logger log.Logger) error {
go fillWorkers[i].bitmapCode()
}
for atomic.LoadUint64(&doneCount) < uint64(workerCount) {
select {
case <-logEvery.C:
for range logEvery.C {
var m runtime.MemStats
libcommon.ReadMemStats(&m)
var p float64
@ -775,8 +772,7 @@ func Recon(genesis *core.Genesis, logger log.Logger) error {
go fillWorkers[i].fillAccounts(plainStateCollectors[i])
}
for atomic.LoadUint64(&doneCount) < uint64(workerCount) {
select {
case <-logEvery.C:
for range logEvery.C {
var m runtime.MemStats
libcommon.ReadMemStats(&m)
var p float64
@ -797,8 +793,7 @@ func Recon(genesis *core.Genesis, logger log.Logger) error {
go fillWorkers[i].fillStorage(plainStateCollectors[i])
}
for atomic.LoadUint64(&doneCount) < uint64(workerCount) {
select {
case <-logEvery.C:
for range logEvery.C {
var m runtime.MemStats
libcommon.ReadMemStats(&m)
var p float64
@ -819,8 +814,7 @@ func Recon(genesis *core.Genesis, logger log.Logger) error {
go fillWorkers[i].fillCode(codeCollectors[i], plainContractCollectors[i])
}
for atomic.LoadUint64(&doneCount) < uint64(workerCount) {
select {
case <-logEvery.C:
for range logEvery.C {
var m runtime.MemStats
libcommon.ReadMemStats(&m)
var p float64