mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 20:17:17 +00:00
8c376082ff
* move locking to the hd object itself, create ready channel * Fix lint * More integration * Fix lint * Connect to processing * Set hd.files at recovery * Serialise processSegment * Fix lint * Not prepend filesDir * Write to the database * Fix lint * Set up genesis block * Fix hard coded tips * Fix chainbreak false alarm * Recover from DB * Skip non-header records * Not initialise if recovered from DB * Fix lint
34 lines
850 B
Go
34 lines
850 B
Go
package check
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/common"
|
|
"github.com/ledgerwatch/turbo-geth/log"
|
|
"github.com/ledgerwatch/turbo-geth/turbo/stages/headerdownload"
|
|
)
|
|
|
|
func Check(filesDir string) error {
|
|
log.Info("Checking", "directory", filesDir)
|
|
hd := headerdownload.NewHeaderDownload(
|
|
common.Hash{}, /* initialHash */
|
|
filesDir,
|
|
32*1024, /* bufferLimit */
|
|
16*1024, /* tipLimit */
|
|
1024, /* initPowDepth */
|
|
nil,
|
|
nil,
|
|
3600, /* newAnchor future limit */
|
|
3600, /* newAnchor past limit */
|
|
)
|
|
if recovered, err := hd.RecoverFromFiles(uint64(time.Now().Unix()), make(map[common.Hash]struct{})); err != nil || !recovered {
|
|
if err != nil {
|
|
log.Error("Recovery from file failed, will start from scratch", "error", err)
|
|
} else {
|
|
log.Info("Nothing recovered")
|
|
}
|
|
}
|
|
log.Info(hd.AnchorState())
|
|
return nil
|
|
}
|