mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-04 01:54:28 +00:00
f06db2f37b
* save state * add current index feature * fix test * remove logs * Only execute 1000 blocks * Reset history index * Correct action * Increase batch size * Increase chunk size, print memory stats * Fix linter * Remove unused from * Split into 2 staged * Use storage history gen * remove log * Not to run tx_cacher in staged mode * Not to recover during stage 2 * Not to recover during stage 2 * Remove counter Co-authored-by: b00ris <b00ris@mail.ru>
38 lines
967 B
Go
38 lines
967 B
Go
package generate
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"github.com/ledgerwatch/turbo-geth/common/changeset"
|
|
"github.com/ledgerwatch/turbo-geth/common/dbutils"
|
|
"github.com/ledgerwatch/turbo-geth/core"
|
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
|
)
|
|
|
|
func RegenerateIndex(chaindata string, indexBucket []byte, csBucket []byte) error {
|
|
db, err := ethdb.NewBoltDatabase(chaindata)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
var walker func([]byte) core.ChangesetWalker
|
|
if bytes.Equal(dbutils.AccountChangeSetBucket, csBucket) {
|
|
walker = func(cs []byte) core.ChangesetWalker {
|
|
return changeset.AccountChangeSetBytes(cs)
|
|
}
|
|
}
|
|
|
|
if bytes.Equal(dbutils.StorageChangeSetBucket, csBucket) {
|
|
walker = func(cs []byte) core.ChangesetWalker {
|
|
return changeset.StorageChangeSetBytes(cs)
|
|
}
|
|
}
|
|
|
|
ig := core.NewIndexGenerator(db)
|
|
err = ig.GenerateIndex(0, csBucket, indexBucket, walker, nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println("Index is successfully regenerated")
|
|
return nil
|
|
}
|