Refactor to use statediff plugin #1

Merged
roysc merged 27 commits from refactor-use-plugin into v5 2023-09-29 18:43:28 +00:00
Showing only changes of commit 5b0cc124a5 - Show all commits

View File

@ -85,13 +85,12 @@ type SnapshotParams struct {
func (s *Service) CreateSnapshot(params SnapshotParams) error {
// extract header from lvldb and publish to PG-IPFS
// hold onto the headerID so that we can link the state nodes to this header
log.Infof("Creating snapshot at height %d", params.Height)
hash := rawdb.ReadCanonicalHash(s.ethDB, params.Height)
header := rawdb.ReadHeader(s.ethDB, hash, params.Height)
if header == nil {
return fmt.Errorf("unable to read canonical header at height %d", params.Height)
}
log.Infof("head hash: %s head height: %d", hash.Hex(), params.Height)
log.Info("Creating snapshot", "height", params.Height, "hash", hash)
// Context for snapshot work
ctx, cancelCtx := context.WithCancel(context.Background())
@ -157,7 +156,7 @@ func (s *Service) CreateLatestSnapshot(workers uint, watchedAddresses []common.A
hash := rawdb.ReadHeadHeaderHash(s.ethDB)
height := rawdb.ReadHeaderNumber(s.ethDB, hash)
if height == nil {
return fmt.Errorf("unable to read header height for header hash %s", hash.String())
return fmt.Errorf("unable to read header height for header hash %s", hash)
}
return s.CreateSnapshot(SnapshotParams{Height: *height, Workers: workers, WatchedAddresses: watchedAddresses})
}