@@ -103,7 +103,7 @@ func (u *upgradeManager) CancelUpgrade(ctx context.Context) error {
103103 return nil
104104}
105105
106- func (u * upgradeManager ) checkStatus () error {
106+ func (u * upgradeManager ) checkStatus (dataDir string ) error {
107107 var err error
108108
109109 if err = u .store .GetCBOR (metadataStoreKey , & u .pending ); err != nil {
@@ -123,10 +123,6 @@ func (u *upgradeManager) checkStatus() error {
123123
124124 // By this point, the descriptor is valid and still pending.
125125 if u .pending .UpgradeHeight == api .InvalidUpgradeHeight {
126- // Only allow the old binary to run before the upgrade epoch.
127- if u .pending .SubmittingVersion != thisVersion {
128- return api .ErrNewTooSoon
129- }
130126 return nil
131127 }
132128
@@ -145,7 +141,11 @@ func (u *upgradeManager) checkStatus() error {
145141 return api .ErrUpgradePending
146142 }
147143
148- // In case the previous startup was e.g. interruptd during the second part of the
144+ // We are running the correct version, setup handler.
145+ u .ctx = migrations .NewContext (u .pending , dataDir )
146+ u .handler = migrations .GetHandler (u .ctx )
147+
148+ // In case the previous startup was e.g. interrupted during the second part of the
149149 // upgrade, we need to make sure that we're the same version as the previous run.
150150 if u .pending .RunningVersion != "" && u .pending .RunningVersion != thisVersion {
151151 return api .ErrInvalidResumingVersion
@@ -274,14 +274,9 @@ func New(store *persistent.CommonStore, dataDir string) (api.Backend, error) {
274274 logger : logging .GetLogger (api .ModuleName ),
275275 }
276276
277- if err := upgrader .checkStatus (); err != nil {
277+ if err := upgrader .checkStatus (dataDir ); err != nil {
278278 return nil , err
279279 }
280280
281- if upgrader .pending != nil {
282- upgrader .ctx = migrations .NewContext (upgrader .pending , dataDir )
283- upgrader .handler = migrations .GetHandler (upgrader .ctx )
284- }
285-
286281 return upgrader , nil
287282}
0 commit comments