Merge pull request #833 from touhonoob/embed-wallet-ini
[wallet] embed wallet.ini into wallet binary (#830)pull/838/head
commit
7fa822cb66
@ -0,0 +1,44 @@ |
||||
package main |
||||
|
||||
const ( |
||||
defaultWalletIni = `[default] |
||||
bootnode = /ip4/100.26.90.187/tcp/9876/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxAqFSGA9 |
||||
bootnode = /ip4/54.213.43.194/tcp/9876/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX |
||||
shards = 1 |
||||
|
||||
[default.shard0.rpc] |
||||
rpc = 34.217.179.222:14555 |
||||
rpc = 18.209.247.105:14555 |
||||
rpc = 100.25.248.42:14555 |
||||
rpc = 3.80.164.193:14555 |
||||
rpc = 54.87.237.93:14555 |
||||
|
||||
[local] |
||||
bootnode = /ip4/127.0.0.1/tcp/19876/p2p/Qmc1V6W7BwX8Ugb42Ti8RnXF1rY5PF7nnZ6bKBryCgi6cv |
||||
shards = 1 |
||||
|
||||
[local.shard0.rpc] |
||||
rpc = 127.0.0.1:14555 |
||||
rpc = 127.0.0.1:14556 |
||||
|
||||
[devnet] |
||||
bootnode = /ip4/100.26.90.187/tcp/9871/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv |
||||
bootnode = /ip4/54.213.43.194/tcp/9871/p2p/QmRVbTpEYup8dSaURZfF6ByrMTSKa4UyUzJhSjahFzRqNj |
||||
shards = 3 |
||||
|
||||
[devnet.shard0.rpc] |
||||
rpc = 13.57.196.136:14555 |
||||
rpc = 35.175.103.144:14555 |
||||
rpc = 54.245.176.36:14555 |
||||
|
||||
[devnet.shard1.rpc] |
||||
rpc = 35.163.188.234:14555 |
||||
rpc = 54.215.251.123:14555 |
||||
rpc = 54.153.11.146:14555 |
||||
|
||||
[devnet.shard2.rpc] |
||||
rpc = 52.201.246.212:14555 |
||||
rpc = 3.81.26.139:14555 |
||||
rpc = 18.237.42.209:14555 |
||||
` |
||||
) |
@ -0,0 +1,64 @@ |
||||
package utils |
||||
|
||||
import ( |
||||
"fmt" |
||||
"io" |
||||
"os" |
||||
"path/filepath" |
||||
|
||||
"github.com/iancoleman/strcase" |
||||
) |
||||
|
||||
// EmbedFile Text file embed script for go:generate.
|
||||
// This script embeds a text file located at filePath into a string constant
|
||||
// named as constName defined in a golang source file located at the current
|
||||
// go:generate path.
|
||||
func EmbedFile(filePath string, constName string) { |
||||
// validate inputs
|
||||
if _, err := os.Stat(filePath); os.IsNotExist(err) { |
||||
panic(fmt.Sprintf("File %s does not exist", filePath)) |
||||
} |
||||
|
||||
if strcase.ToLowerCamel(constName) != constName { |
||||
panic(fmt.Sprintf("constName %s is not in lower camel-case", constName)) |
||||
} |
||||
|
||||
// generate go file
|
||||
var err error |
||||
fileName := filepath.Base(filePath) |
||||
generatedFileName := "generated_" + strcase.ToSnake(fileName) + ".go" |
||||
out, err := os.Create(generatedFileName) |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
|
||||
_, err = out.Write([]byte(fmt.Sprintf("package %s\n\nconst (\n", os.Getenv("GOPACKAGE")))) |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
|
||||
_, err = out.Write([]byte("\t" + constName + " = `")) |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
|
||||
f, err := os.Open(filePath) |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
|
||||
_, err = io.Copy(out, f) |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
|
||||
_, err = out.Write([]byte("`\n")) |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
|
||||
_, err = out.Write([]byte(")\n")) |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
} |
@ -0,0 +1,8 @@ |
||||
package main |
||||
|
||||
import "github.com/harmony-one/harmony/internal/utils" |
||||
|
||||
// Embed the default wallet.ini file into defaultWalletIni string literal constant
|
||||
func main() { |
||||
utils.EmbedFile("../../../.hmy/wallet.ini", "defaultWalletIni") |
||||
} |
Loading…
Reference in new issue