feat(store): add new api LatestVersion (#22305)

This commit is contained in:
cool-developer
2024-10-21 13:09:58 +00:00
committed by GitHub
parent 6e59ad0dee
commit 97d37ae243
8 changed files with 27 additions and 2 deletions
+4
View File
@@ -36,6 +36,10 @@ func (cdsa commitDBStoreAdapter) LastCommitID() types.CommitID {
}
}
func (cdsa commitDBStoreAdapter) LatestVersion() int64 {
return -1
}
func (cdsa commitDBStoreAdapter) WorkingHash() []byte {
return commithash
}
+5 -1
View File
@@ -434,7 +434,11 @@ func (rs *Store) PopStateCache() []*types.StoreKVPair {
// LatestVersion returns the latest version in the store
func (rs *Store) LatestVersion() int64 {
return rs.LastCommitID().Version
if rs.lastCommitInfo == nil {
return GetLatestVersion(rs.db)
}
return rs.lastCommitInfo.Version
}
// LastCommitID implements Committer/CommitStore.