Skip to content

Commit

Permalink
Merge pull request #62 from sei-protocol/ReadOnlyCreateDBIssue
Browse files Browse the repository at this point in the history
Set CreateIfMissing to false when copyExisting
  • Loading branch information
Kbhat1 authored Apr 12, 2024
2 parents 7e47a5c + e295940 commit 22bf439
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions sc/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,18 @@ func (cs *CommitStore) Rollback(targetVersion int64) error {
return nil
}

func (cs *CommitStore) LoadVersion(targetVersion int64, createNew bool) (types.Committer, error) {
// copyExisting is for creating new memiavl object given existing folder
func (cs *CommitStore) LoadVersion(targetVersion int64, copyExisting bool) (types.Committer, error) {
opts := cs.opts
opts.ReadOnly = createNew
opts.ReadOnly = copyExisting
if copyExisting {
opts.CreateIfMissing = false
}
db, err := memiavl.OpenDB(cs.logger, targetVersion, opts)
if err != nil {
return nil, err
}
if createNew {
if copyExisting {
return &CommitStore{
logger: cs.logger,
db: db,
Expand Down
2 changes: 1 addition & 1 deletion sc/types/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Committer interface {

LastCommitInfo() *proto.CommitInfo

LoadVersion(targetVersion int64, createNew bool) (Committer, error)
LoadVersion(targetVersion int64, copyExisting bool) (Committer, error)

Rollback(targetVersion int64) error

Expand Down

0 comments on commit 22bf439

Please sign in to comment.