diff --git a/bchain/coins/blockchain.go b/bchain/coins/blockchain.go index 98bb4efd..a8d8c95a 100644 --- a/bchain/coins/blockchain.go +++ b/bchain/coins/blockchain.go @@ -55,20 +55,21 @@ func init() { } // GetCoinNameFromConfig gets coin name and coin shortcut from config file -func GetCoinNameFromConfig(configfile string) (string, string, error) { +func GetCoinNameFromConfig(configfile string) (string, string, string, error) { data, err := ioutil.ReadFile(configfile) if err != nil { - return "", "", errors.Annotatef(err, "Error reading file %v", configfile) + return "", "", "", errors.Annotatef(err, "Error reading file %v", configfile) } var cn struct { CoinName string `json:"coin_name"` CoinShortcut string `json:"coin_shortcut"` + CoinLabel string `json:"coin_label"` } err = json.Unmarshal(data, &cn) if err != nil { - return "", "", errors.Annotatef(err, "Error parsing file %v", configfile) + return "", "", "", errors.Annotatef(err, "Error parsing file %v", configfile) } - return cn.CoinName, cn.CoinShortcut, nil + return cn.CoinName, cn.CoinShortcut, cn.CoinLabel, nil } // NewBlockChain creates bchain.BlockChain of type defined by parameter coin diff --git a/blockbook.go b/blockbook.go index 769e7ff2..a9627290 100644 --- a/blockbook.go +++ b/blockbook.go @@ -152,7 +152,7 @@ func main() { glog.Fatal("Missing blockchaincfg configuration parameter") } - coin, coinShortcut, err := coins.GetCoinNameFromConfig(*blockchain) + coin, coinShortcut, coinLabel, err := coins.GetCoinNameFromConfig(*blockchain) if err != nil { glog.Fatal("config: ", err) } @@ -174,7 +174,7 @@ func main() { } defer index.Close() - internalState, err = newInternalState(coin, coinShortcut, index) + internalState, err = newInternalState(coin, coinShortcut, coinLabel, index) if err != nil { glog.Error("internalState: ", err) return @@ -369,12 +369,16 @@ func blockbookAppInfoMetric(db *db.RocksDB, chain bchain.BlockChain, txCache *db return nil } -func newInternalState(coin string, coinShortcut string, d *db.RocksDB) (*common.InternalState, error) { +func newInternalState(coin, coinShortcut, coinLabel string, d *db.RocksDB) (*common.InternalState, error) { is, err := d.LoadInternalState(coin) if err != nil { return nil, err } is.CoinShortcut = coinShortcut + if coinLabel == "" { + coinLabel = coin + } + is.CoinLabel = coinLabel name, err := os.Hostname() if err != nil { glog.Error("get hostname ", err) diff --git a/build/templates/blockbook/blockchaincfg.json b/build/templates/blockbook/blockchaincfg.json index f8acb70b..159eba57 100644 --- a/build/templates/blockbook/blockchaincfg.json +++ b/build/templates/blockbook/blockchaincfg.json @@ -8,6 +8,7 @@ "coin_name": "{{.Coin.Name}}", "coin_shortcut": "{{.Coin.Shortcut}}", + "coin_label": "{{.Coin.Label}}", "rpc_url": "{{template "IPC.RPCURLTemplate" .}}", "rpc_user": "{{.IPC.RPCUser}}", "rpc_pass": "{{.IPC.RPCPass}}", diff --git a/common/internalstate.go b/common/internalstate.go index 9479d057..f19fd1f8 100644 --- a/common/internalstate.go +++ b/common/internalstate.go @@ -31,6 +31,7 @@ type InternalState struct { Coin string `json:"coin"` CoinShortcut string `json:"coinShortcut"` + CoinLabel string `json:"coinLabel"` Host string `json:"host"` DbState uint32 `json:"dbState"` diff --git a/configs/coins/bitcoin_testnet.json b/configs/coins/bitcoin_testnet.json index a2ef7e0d..913e7e60 100644 --- a/configs/coins/bitcoin_testnet.json +++ b/configs/coins/bitcoin_testnet.json @@ -2,7 +2,7 @@ "coin": { "name": "Testnet", "shortcut": "TEST", - "label": "Testnet", + "label": "Bitcoin Testnet", "alias": "bitcoin_testnet" }, "ports": { diff --git a/server/public.go b/server/public.go index 79b40912..48ee1e79 100644 --- a/server/public.go +++ b/server/public.go @@ -228,6 +228,7 @@ func (s *PublicServer) newTemplateData() *TemplateData { return &TemplateData{ CoinName: s.is.Coin, CoinShortcut: s.is.CoinShortcut, + CoinLabel: s.is.CoinLabel, InternalExplorer: s.internalExplorer && !s.is.InitialSync, } } @@ -311,6 +312,7 @@ const ( type TemplateData struct { CoinName string CoinShortcut string + CoinLabel string InternalExplorer bool Address *api.Address AddrStr string diff --git a/static/templates/base.html b/static/templates/base.html index 05bebd41..9f5103c4 100644 --- a/static/templates/base.html +++ b/static/templates/base.html @@ -29,7 +29,7 @@ {{- if .InternalExplorer -}}