Skip to content

Commit 244cbc5

Browse files
committed
Problem: batch initialization when fixdata with dry-run is unnecessary (crypto-org-chain#1747)
* Problem: need batch initialization run fixdata with dry-run * mod tidy * skip flush
1 parent 6a6f7b5 commit 244cbc5

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
### Improvements
3232

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

3536
*Dec 2, 2024*
3637

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ require (
5656
cloud.google.com/go/storage v1.41.0 // indirect
5757
cosmossdk.io/collections v0.4.0 // indirect
5858
cosmossdk.io/depinject v1.0.0 // indirect
59-
cosmossdk.io/x/tx v0.13.6-0.20241003112805-ff8789a02871 // indirect
59+
cosmossdk.io/x/tx v0.13.7 // indirect
6060
filippo.io/edwards25519 v1.1.0 // indirect
6161
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
6262
github.com/DataDog/datadog-go v4.8.3+incompatible // indirect

gomod2nix.toml

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

versiondb/tsrocksdb/store.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ func (s Store) FixData(storeNames []string, dryRun bool) error {
241241
return err
242242
}
243243
}
244-
244+
if dryRun {
245+
return nil
246+
}
245247
return s.Flush()
246248
}
247249

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

255-
batch := grocksdb.NewWriteBatch()
256-
defer batch.Destroy()
257+
var batch *grocksdb.WriteBatch
258+
if !dryRun {
259+
batch = grocksdb.NewWriteBatch()
260+
defer batch.Destroy()
261+
}
257262

258263
prefix := storePrefix(storeName)
259264
readOpts := grocksdb.NewDefaultReadOptions()

0 commit comments

Comments
 (0)