erigon-pulse/cmd/state/generate/regenerate_index.go
b00ris 266f9a5208
Plain state index (#595)
* plain state indexes

* generalize index generation&tests

* add plain state tests

* fix regenerate index

* сoncurrent changeset chunks processing

* remove concurrency

* fix lint

* remove comments

* add test to truncate

* fix conflicts

* fmt

* remove shadowing
2020-05-31 07:57:47 +01:00

31 lines
751 B
Go

package generate
import (
"github.com/ledgerwatch/turbo-geth/common/dbutils"
"github.com/ledgerwatch/turbo-geth/core"
"github.com/ledgerwatch/turbo-geth/ethdb"
"github.com/ledgerwatch/turbo-geth/log"
"time"
)
func RegenerateIndex(chaindata string, csBucket []byte) error {
db, err := ethdb.NewBoltDatabase(chaindata)
if err != nil {
return err
}
ig := core.NewIndexGenerator(db, make(chan struct{}))
err = ig.DropIndex(dbutils.AccountsHistoryBucket)
if err != nil {
return err
}
startTime := time.Now()
log.Info("Index generation started", "start time", startTime)
err = ig.GenerateIndex(0, csBucket)
if err != nil {
return err
}
log.Info("Index is successfully regenerated", "it took", time.Since(startTime))
return nil
}