|
1 | 1 | package seiconfig |
2 | 2 |
|
| 3 | +import "strings" |
| 4 | + |
3 | 5 | // Legacy types match the existing config.toml (Tendermint) and app.toml |
4 | 6 | // (Cosmos SDK + Sei) TOML schemas exactly. These are used during Phase 2 |
5 | 7 | // for reading/writing the two-file layout and will be removed when the |
@@ -103,9 +105,9 @@ type legacyMempool struct { |
103 | 105 | } |
104 | 106 |
|
105 | 107 | type legacyStateSync struct { |
106 | | - Enable bool `toml:"enable"` |
107 | | - UseP2P bool `toml:"use-p2p"` |
108 | | - RPCServers []string `toml:"rpc-servers"` |
| 108 | + Enable bool `toml:"enable"` |
| 109 | + UseP2P bool `toml:"use-p2p"` |
| 110 | + RPCServers string `toml:"rpc-servers"` |
109 | 111 | TrustHeight int64 `toml:"trust-height"` |
110 | 112 | TrustHash string `toml:"trust-hash"` |
111 | 113 | TrustPeriod Duration `toml:"trust-period"` |
@@ -441,7 +443,7 @@ func (cfg *SeiConfig) toLegacyTendermint() legacyTendermintConfig { |
441 | 443 | StateSync: legacyStateSync{ |
442 | 444 | Enable: cfg.StateSync.Enable, |
443 | 445 | UseP2P: cfg.StateSync.UseP2P, |
444 | | - RPCServers: cfg.StateSync.RPCServers, |
| 446 | + RPCServers: strings.Join(cfg.StateSync.RPCServers, ","), |
445 | 447 | TrustHeight: cfg.StateSync.TrustHeight, |
446 | 448 | TrustHash: cfg.StateSync.TrustHash, |
447 | 449 | TrustPeriod: cfg.StateSync.TrustPeriod, |
@@ -783,7 +785,7 @@ func fromLegacy(tm legacyTendermintConfig, app legacyAppConfig) *SeiConfig { |
783 | 785 | StateSync: StateSyncConfig{ |
784 | 786 | Enable: tm.StateSync.Enable, |
785 | 787 | UseP2P: tm.StateSync.UseP2P, |
786 | | - RPCServers: tm.StateSync.RPCServers, |
| 788 | + RPCServers: splitRPCServers(tm.StateSync.RPCServers), |
787 | 789 | TrustHeight: tm.StateSync.TrustHeight, |
788 | 790 | TrustHash: tm.StateSync.TrustHash, |
789 | 791 | TrustPeriod: tm.StateSync.TrustPeriod, |
@@ -967,3 +969,20 @@ func fromLegacy(tm legacyTendermintConfig, app legacyAppConfig) *SeiConfig { |
967 | 969 | }, |
968 | 970 | } |
969 | 971 | } |
| 972 | + |
| 973 | +// splitRPCServers converts a Tendermint-style comma-separated rpc-servers |
| 974 | +// string into the []string used by SeiConfig. Returns nil for empty input. |
| 975 | +func splitRPCServers(s string) []string { |
| 976 | + s = strings.TrimSpace(s) |
| 977 | + if s == "" { |
| 978 | + return nil |
| 979 | + } |
| 980 | + parts := strings.Split(s, ",") |
| 981 | + out := make([]string, 0, len(parts)) |
| 982 | + for _, p := range parts { |
| 983 | + if t := strings.TrimSpace(p); t != "" { |
| 984 | + out = append(out, t) |
| 985 | + } |
| 986 | + } |
| 987 | + return out |
| 988 | +} |
0 commit comments