File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -549,9 +549,12 @@ func (rs *Store) SetInitialVersion(version int64) error {
549549
550550 // Loop through all the stores, if it's an IAVL store, then set initial
551551 // version on it.
552- for _ , commitKVStore := range rs .stores {
553- if storeWithVersion , ok := commitKVStore .(types.StoreWithInitialVersion ); ok {
554- storeWithVersion .SetInitialVersion (version )
552+ for key , store := range rs .stores {
553+ if store .GetStoreType () == types .StoreTypeIAVL {
554+ // If the store is wrapped with an inter-block cache, we must first unwrap
555+ // it to get the underlying IAVL store.
556+ store = rs .GetCommitKVStore (key )
557+ store .(* iavl.Store ).SetInitialVersion (version )
555558 }
556559 }
557560
Original file line number Diff line number Diff line change @@ -657,11 +657,18 @@ func TestSetInitialVersion(t *testing.T) {
657657 db := dbm .NewMemDB ()
658658 multi := newMultiStoreWithMounts (db , types .PruneNothing )
659659
660+ require .NoError (t , multi .LoadLatestVersion ())
661+
660662 multi .SetInitialVersion (5 )
661663 require .Equal (t , int64 (5 ), multi .initialVersion )
662664
663665 multi .Commit ()
664666 require .Equal (t , int64 (5 ), multi .LastCommitID ().Version )
667+
668+ ckvs := multi .GetCommitKVStore (multi .keysByName ["store1" ])
669+ iavlStore , ok := ckvs .(* iavl.Store )
670+ require .True (t , ok )
671+ require .True (t , iavlStore .VersionExists (5 ))
665672}
666673
667674func BenchmarkMultistoreSnapshot100K (b * testing.B ) {
You can’t perform that action at this time.
0 commit comments