add guard

This commit is contained in:
Ian Norden 2020-07-16 10:02:16 -05:00
parent da0157a64b
commit 367a9b4577

View File

@ -67,6 +67,9 @@ func (s *Service) CreateSnapshot(height uint64) error {
logrus.Infof("Creating snapshot at height %d", height)
hash := rawdb.ReadCanonicalHash(s.ethDB, height)
header := rawdb.ReadHeader(s.ethDB, hash, height)
if header == nil {
return fmt.Errorf("unable to read canonical header at height %d", height)
}
headerID, err := s.ipfsPublisher.PublishHeader(header)
if err != nil {
return err