Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check new state mgmt service is compatible with DB (#5231)
- Loading branch information
1 parent
b40e6db
commit c67b01e
Showing
4 changed files
with
42 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package kv | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/prysmaticlabs/prysm/shared/featureconfig" | ||
bolt "go.etcd.io/bbolt" | ||
) | ||
|
||
var historicalStateDeletedKey = []byte("historical-states-deleted") | ||
|
||
func (kv *Store) ensureNewStateServiceCompatible() error { | ||
if !featureconfig.Get().NewStateMgmt { | ||
return kv.db.Update(func(tx *bolt.Tx) error { | ||
bkt := tx.Bucket(newStateServiceCompatibleBucket) | ||
return bkt.Put(historicalStateDeletedKey, []byte{0x01}) | ||
}) | ||
} | ||
|
||
var historicalStateDeleted bool | ||
kv.db.View(func(tx *bolt.Tx) error { | ||
bkt := tx.Bucket(newStateServiceCompatibleBucket) | ||
v := bkt.Get(historicalStateDeletedKey) | ||
historicalStateDeleted = len(v) == 1 && v[0] == 0x01 | ||
return nil | ||
}) | ||
|
||
if historicalStateDeleted { | ||
return errors.New("historical states were pruned in db, do not run with flag --new-state-mgmt") | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters