Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph committed Aug 19, 2024
1 parent 11bcdef commit 612dc93
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions vms/platformvm/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,10 +665,10 @@ func New(
}

if err := s.sync(genesisBytes); err != nil {
// Drop any errors on close to return the first error
_ = s.Close()

return nil, err
return nil, errors.Join(
err,
s.Close(),
)
}

return s, nil
Expand Down Expand Up @@ -1719,17 +1719,17 @@ func (s *state) Close() error {
}

func (s *state) sync(genesis []byte) error {
isInitialized, err := isInitialized(s.singletonDB)
wasInitialized, err := isInitialized(s.singletonDB)
if err != nil {
return fmt.Errorf(
"failed to check if the database is initialized: %w",
err,
)
}

// If the database is empty, create the platform chain anew using the
// provided genesis state
if !isInitialized {
// If the database wasn't previously initialized, create the platform chain
// anew using the provided genesis state.
if !wasInitialized {
if err := s.init(genesis); err != nil {
return fmt.Errorf(
"failed to initialize the database: %w",
Expand Down

0 comments on commit 612dc93

Please sign in to comment.