Skip to content

Commit

Permalink
Problem: batch initialization when fixdata with dry-run is unnecessary (
Browse files Browse the repository at this point in the history
#1747)

* Problem: need batch initialization run fixdata with dry-run

* mod tidy

* skip flush
  • Loading branch information
mmsqe authored Feb 14, 2025
1 parent 5bdb927 commit b2742e2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
### Improvements

* [#1712](https://github.com/crypto-org-chain/cronos/pull/1712) Upgrade rocksdb to `v9.8.4`.
* [#1747](https://github.com/crypto-org-chain/cronos/pull/1747) Skip batch initialization and flush when fixdata with dry-run.

*Dec 2, 2024*

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ require (
cloud.google.com/go/storage v1.41.0 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/depinject v1.0.0 // indirect
cosmossdk.io/x/tx v0.13.6-0.20241003112805-ff8789a02871 // indirect
cosmossdk.io/x/tx v0.13.7 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/DataDog/datadog-go v4.8.3+incompatible // indirect
Expand Down
5 changes: 3 additions & 2 deletions versiondb/go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module github.com/crypto-org-chain/cronos/versiondb

go 1.22.7
toolchain go1.23.1
go 1.22.11

toolchain go1.23.6

require (
cosmossdk.io/errors v1.0.1
Expand Down
11 changes: 8 additions & 3 deletions versiondb/tsrocksdb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ func (s Store) FixData(storeNames []string, dryRun bool) error {
return err
}
}

if dryRun {
return nil
}
return s.Flush()
}

Expand All @@ -252,8 +254,11 @@ func (s Store) fixDataStore(storeName string, dryRun bool) error {
return err
}

batch := grocksdb.NewWriteBatch()
defer batch.Destroy()
var batch *grocksdb.WriteBatch
if !dryRun {
batch = grocksdb.NewWriteBatch()
defer batch.Destroy()
}

prefix := storePrefix(storeName)
readOpts := grocksdb.NewDefaultReadOptions()
Expand Down

0 comments on commit b2742e2

Please sign in to comment.