Refactor to use statediff plugin #1
@ -85,13 +85,12 @@ type SnapshotParams struct {
|
|||||||
func (s *Service) CreateSnapshot(params SnapshotParams) error {
|
func (s *Service) CreateSnapshot(params SnapshotParams) error {
|
||||||
// extract header from lvldb and publish to PG-IPFS
|
// extract header from lvldb and publish to PG-IPFS
|
||||||
// hold onto the headerID so that we can link the state nodes to this header
|
// 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)
|
hash := rawdb.ReadCanonicalHash(s.ethDB, params.Height)
|
||||||
header := rawdb.ReadHeader(s.ethDB, hash, params.Height)
|
header := rawdb.ReadHeader(s.ethDB, hash, params.Height)
|
||||||
if header == nil {
|
if header == nil {
|
||||||
return fmt.Errorf("unable to read canonical header at height %d", params.Height)
|
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
|
// Context for snapshot work
|
||||||
ctx, cancelCtx := context.WithCancel(context.Background())
|
ctx, cancelCtx := context.WithCancel(context.Background())
|
||||||
@ -157,7 +156,7 @@ func (s *Service) CreateLatestSnapshot(workers uint, watchedAddresses []common.A
|
|||||||
hash := rawdb.ReadHeadHeaderHash(s.ethDB)
|
hash := rawdb.ReadHeadHeaderHash(s.ethDB)
|
||||||
height := rawdb.ReadHeaderNumber(s.ethDB, hash)
|
height := rawdb.ReadHeaderNumber(s.ethDB, hash)
|
||||||
if height == nil {
|
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})
|
return s.CreateSnapshot(SnapshotParams{Height: *height, Workers: workers, WatchedAddresses: watchedAddresses})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user