Skip to content

Commit

Permalink
Merge pull request #61 from sei-protocol/yzang/SEI-6822
Browse files Browse the repository at this point in the history
LoadVersion should open DB with read only
  • Loading branch information
philipsu522 authored Mar 11, 2024
2 parents e4f3ec3 + 6f476d4 commit 7e47a5c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sc/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,17 @@ func (cs *CommitStore) Rollback(targetVersion int64) error {
}

func (cs *CommitStore) LoadVersion(targetVersion int64, createNew bool) (types.Committer, error) {
db, err := memiavl.OpenDB(cs.logger, targetVersion, cs.opts)
opt := cs.opts
opts := cs.opts
opts.ReadOnly = createNew
db, err := memiavl.OpenDB(cs.logger, targetVersion, opts)
if err != nil {
return nil, err
}
if createNew {
// we need to set readonly to true since we create new db only for read
opt.ReadOnly = true
return &CommitStore{
logger: cs.logger,
db: db,
opts: opt,
opts: opts,
}, nil
}
cs.db = db
Expand Down

0 comments on commit 7e47a5c

Please sign in to comment.