mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-01 00:31:21 +00:00
266f9a5208
* 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
31 lines
751 B
Go
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
|
|
}
|