From 1a2cc933a0b5e5204ee21f9ab82b7243a475ebe7 Mon Sep 17 00:00:00 2001 From: Erik Grinaker Date: Thu, 1 Oct 2020 15:55:57 +0200 Subject: [PATCH] config: set statesync.rpc_servers when generating config file (#5433) (#5438) Required for #5291, to generate configuration files with state sync RPC servers. --- CHANGELOG_PENDING.md | 2 ++ config/toml.go | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 96f794c77..402e0db20 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -22,5 +22,7 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi ### IMPROVEMENTS +- [config] \#5433 `statesync.rpc_servers` is now properly set when writing the configuration file (@erikgrinaker) + ### BUG FIXES diff --git a/config/toml.go b/config/toml.go index 275057d66..260eda7cd 100644 --- a/config/toml.go +++ b/config/toml.go @@ -5,6 +5,7 @@ import ( "fmt" "io/ioutil" "path/filepath" + "strings" "text/template" tmos "github.com/tendermint/tendermint/libs/os" @@ -17,7 +18,10 @@ var configTemplate *template.Template func init() { var err error - if configTemplate, err = template.New("configFileTemplate").Parse(defaultConfigTemplate); err != nil { + tmpl := template.New("configFileTemplate").Funcs(template.FuncMap{ + "StringsJoin": strings.Join, + }) + if configTemplate, err = tmpl.Parse(defaultConfigTemplate); err != nil { panic(err) } } @@ -350,7 +354,7 @@ enable = {{ .StateSync.Enable }} # # For Cosmos SDK-based chains, trust_period should usually be about 2/3 of the unbonding time (~2 # weeks) during which they can be financially punished (slashed) for misbehavior. -rpc_servers = "" +rpc_servers = "{{ StringsJoin .StateSync.RPCServers "," }}" trust_height = {{ .StateSync.TrustHeight }} trust_hash = "{{ .StateSync.TrustHash }}" trust_period = "{{ .StateSync.TrustPeriod }}"