Skip to content

Commit

Permalink
some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
renaynay committed Jan 17, 2025
1 parent 794789c commit c4ec028
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion nodebuilder/pruner/migration_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ func detectFirstRun(ctx context.Context, cfg *Config, ds datastore.Datastore, la
"datastore: %w", err)
}
if exists {
// node has already been run on current version, no migration is necessary
return nil
}

// if service is not enabled, service is archival
isArchival := !cfg.EnableService

// if the node has been pruned before on a previous version, it cannot revert
// to archival mode
if isArchival && lastPrunedHeight > 1 {
return fullavail.ErrDisallowRevertToArchival
}
Expand Down
4 changes: 3 additions & 1 deletion nodebuilder/pruner/migration_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ func TestDetectFirstRun(t *testing.T) {
ds := ds_sync.MutexWrap(datastore.NewMapDatastore())

// create archival node instance over a node that has been pruned before
// (height 500)
cfg := &Config{EnableService: false}
lastPrunedHeight := uint64(500)

err := detectFirstRun(ctx, cfg, ds, 500)
err := detectFirstRun(ctx, cfg, ds, lastPrunedHeight)
assert.Error(t, err)
assert.ErrorIs(t, err, fullavail.ErrDisallowRevertToArchival)
})
Expand Down

0 comments on commit c4ec028

Please sign in to comment.