-
Notifications
You must be signed in to change notification settings - Fork 881
Expand file tree
/
Copy pathpath.go
More file actions
71 lines (63 loc) · 2.51 KB
/
path.go
File metadata and controls
71 lines (63 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package utils
import (
"os"
"path/filepath"
)
// PathExists returns true if the given path exists on disk.
func PathExists(path string) bool {
_, err := os.Stat(path)
return err == nil
}
// GetCosmosSCStorePath returns the path for the memiavl state commitment store.
// New nodes use data/state_commit/memiavl; existing nodes with data/committer.db
// continue using the legacy path for backward compatibility.
func GetCosmosSCStorePath(homePath string) string {
legacyPath := filepath.Join(homePath, "data", "committer.db")
if PathExists(legacyPath) {
return legacyPath
}
return filepath.Join(homePath, "data", "state_commit", "memiavl")
}
// GetFlatKVPath returns the path for the FlatKV EVM commit store.
// New nodes use data/state_commit/flatkv; existing nodes with data/flatkv
// continue using the legacy path for backward compatibility.
func GetFlatKVPath(homePath string) string {
legacyPath := filepath.Join(homePath, "data", "flatkv")
if PathExists(legacyPath) {
return legacyPath
}
return filepath.Join(homePath, "data", "state_commit", "flatkv")
}
// GetStateStorePath returns the path for the Cosmos state store (SS).
// New nodes use data/state_store/cosmos/{backend}; existing nodes with
// data/{backend} continue using the legacy path for backward compatibility.
func GetStateStorePath(homePath string, backend string) string {
legacyPath := filepath.Join(homePath, "data", backend)
if PathExists(legacyPath) {
return legacyPath
}
return filepath.Join(homePath, "data", "state_store", "cosmos", backend)
}
// GetEVMStateStorePath returns the path for the EVM state store.
// New nodes use data/state_store/evm/{backend}; existing nodes with
// data/evm_ss continue using the legacy path for backward compatibility.
func GetEVMStateStorePath(homePath string, backend string) string {
legacyPath := filepath.Join(homePath, "data", "evm_ss")
if PathExists(legacyPath) {
return legacyPath
}
return filepath.Join(homePath, "data", "state_store", "evm", backend)
}
// GetReceiptStorePath returns the path for the receipt store.
// New nodes use data/ledger/receipt/{backend}; existing nodes with
// data/receipt.db continue using the legacy path for backward compatibility.
func GetReceiptStorePath(homePath string, backend string) string {
legacyPath := filepath.Join(homePath, "data", "receipt.db")
if PathExists(legacyPath) {
return legacyPath
}
return filepath.Join(homePath, "data", "ledger", "receipt", backend)
}
func GetChangelogPath(dbPath string) string {
return filepath.Join(dbPath, "changelog")
}