mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 06:42:16 +00:00
turn off strict routability every time (#2983)
previously, we're turning it off only when --populate-persistent-peers flag was used, which is obviously incorrect. Fixes https://github.com/cosmos/cosmos-sdk/issues/2983
This commit is contained in:
parent
68b467886a
commit
41eaf0e31d
@ -127,14 +127,31 @@ func testnetFiles(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gather persistent peer addresses.
|
||||||
|
var (
|
||||||
|
persistentPeers string
|
||||||
|
err error
|
||||||
|
)
|
||||||
if populatePersistentPeers {
|
if populatePersistentPeers {
|
||||||
err := populatePersistentPeersInConfigAndWriteIt(config)
|
persistentPeers, err = persistentPeersString(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = os.RemoveAll(outputDir)
|
_ = os.RemoveAll(outputDir)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Overwrite default config.
|
||||||
|
for i := 0; i < nValidators+nNonValidators; i++ {
|
||||||
|
nodeDir := filepath.Join(outputDir, fmt.Sprintf("%s%d", nodeDirPrefix, i))
|
||||||
|
config.SetRoot(nodeDir)
|
||||||
|
config.P2P.AddrBookStrict = false
|
||||||
|
if populatePersistentPeers {
|
||||||
|
config.P2P.PersistentPeers = persistentPeers
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg.WriteConfigFile(filepath.Join(nodeDir, "config", "config.toml"), config)
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Printf("Successfully initialized %v node directories\n", nValidators+nNonValidators)
|
fmt.Printf("Successfully initialized %v node directories\n", nValidators+nNonValidators)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -157,28 +174,16 @@ func hostnameOrIP(i int) string {
|
|||||||
return fmt.Sprintf("%s%d", hostnamePrefix, i)
|
return fmt.Sprintf("%s%d", hostnamePrefix, i)
|
||||||
}
|
}
|
||||||
|
|
||||||
func populatePersistentPeersInConfigAndWriteIt(config *cfg.Config) error {
|
func persistentPeersString(config *cfg.Config) (string, error) {
|
||||||
persistentPeers := make([]string, nValidators+nNonValidators)
|
persistentPeers := make([]string, nValidators+nNonValidators)
|
||||||
for i := 0; i < nValidators+nNonValidators; i++ {
|
for i := 0; i < nValidators+nNonValidators; i++ {
|
||||||
nodeDir := filepath.Join(outputDir, fmt.Sprintf("%s%d", nodeDirPrefix, i))
|
nodeDir := filepath.Join(outputDir, fmt.Sprintf("%s%d", nodeDirPrefix, i))
|
||||||
config.SetRoot(nodeDir)
|
config.SetRoot(nodeDir)
|
||||||
nodeKey, err := p2p.LoadNodeKey(config.NodeKeyFile())
|
nodeKey, err := p2p.LoadNodeKey(config.NodeKeyFile())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return "", err
|
||||||
}
|
}
|
||||||
persistentPeers[i] = p2p.IDAddressString(nodeKey.ID(), fmt.Sprintf("%s:%d", hostnameOrIP(i), p2pPort))
|
persistentPeers[i] = p2p.IDAddressString(nodeKey.ID(), fmt.Sprintf("%s:%d", hostnameOrIP(i), p2pPort))
|
||||||
}
|
}
|
||||||
persistentPeersList := strings.Join(persistentPeers, ",")
|
return strings.Join(persistentPeers, ","), nil
|
||||||
|
|
||||||
for i := 0; i < nValidators+nNonValidators; i++ {
|
|
||||||
nodeDir := filepath.Join(outputDir, fmt.Sprintf("%s%d", nodeDirPrefix, i))
|
|
||||||
config.SetRoot(nodeDir)
|
|
||||||
config.P2P.PersistentPeers = persistentPeersList
|
|
||||||
config.P2P.AddrBookStrict = false
|
|
||||||
|
|
||||||
// overwrite default config
|
|
||||||
cfg.WriteConfigFile(filepath.Join(nodeDir, "config", "config.toml"), config)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user