mirror of
https://github.com/trezor/blockbook.git
synced 2026-02-20 00:51:39 +01:00
Add BNB Smart Chain (#869)
This commit is contained in:
@@ -3,4 +3,5 @@
|
||||
backend/* {{.Env.BackendInstallPath}}/{{.Coin.Alias}}
|
||||
server.conf => {{.Env.BackendInstallPath}}/{{.Coin.Alias}}/{{.Coin.Alias}}.conf
|
||||
client.conf => {{.Env.BackendInstallPath}}/{{.Coin.Alias}}/{{.Coin.Alias}}_client.conf
|
||||
{{if .Backend.ExecScript }}exec.sh => {{.Env.BackendInstallPath}}/{{.Coin.Alias}}/{{.Coin.Alias}}_exec.sh{{end}}
|
||||
{{end}}
|
||||
|
||||
40
build/templates/backend/scripts/bsc.sh
Normal file
40
build/templates/backend/scripts/bsc.sh
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
|
||||
{{define "main" -}}
|
||||
|
||||
set -e
|
||||
|
||||
INSTALL_DIR={{.Env.BackendInstallPath}}/{{.Coin.Alias}}
|
||||
DATA_DIR={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend
|
||||
|
||||
GETH_BIN=$INSTALL_DIR/geth_linux
|
||||
CHAINDATA_DIR=$DATA_DIR/geth/chaindata
|
||||
|
||||
if [ ! -d "$CHAINDATA_DIR" ]; then
|
||||
$GETH_BIN init --datadir $DATA_DIR $INSTALL_DIR/genesis.json
|
||||
fi
|
||||
|
||||
$GETH_BIN \
|
||||
--config $INSTALL_DIR/config.toml \
|
||||
--datadir $DATA_DIR \
|
||||
--port {{.Ports.BackendP2P}} \
|
||||
--http \
|
||||
--http.addr 127.0.0.1 \
|
||||
--http.port {{.Ports.BackendHttp}} \
|
||||
--http.api eth,net,web3,debug,txpool \
|
||||
--http.vhosts '*' \
|
||||
--http.corsdomain '*' \
|
||||
--ws \
|
||||
--ws.addr 127.0.0.1 \
|
||||
--ws.port {{.Ports.BackendRPC}} \
|
||||
--ws.api eth,net,web3,debug,txpool \
|
||||
--ws.origins '*' \
|
||||
--syncmode full \
|
||||
--maxpeers 100 \
|
||||
--rpc.allow-unprotected-txs \
|
||||
--txlookuplimit 0 \
|
||||
--cache 8000 \
|
||||
--ipcdisable \
|
||||
--nat none
|
||||
|
||||
{{end}}
|
||||
43
build/templates/backend/scripts/bsc_archive.sh
Normal file
43
build/templates/backend/scripts/bsc_archive.sh
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
|
||||
{{define "main" -}}
|
||||
|
||||
set -e
|
||||
|
||||
INSTALL_DIR={{.Env.BackendInstallPath}}/{{.Coin.Alias}}
|
||||
DATA_DIR={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend
|
||||
|
||||
GETH_BIN=$INSTALL_DIR/geth_linux
|
||||
CHAINDATA_DIR=$DATA_DIR/geth/chaindata
|
||||
|
||||
if [ ! -d "$CHAINDATA_DIR" ]; then
|
||||
$GETH_BIN init --datadir $DATA_DIR $INSTALL_DIR/genesis.json
|
||||
fi
|
||||
|
||||
$GETH_BIN \
|
||||
--config $INSTALL_DIR/config.toml \
|
||||
--datadir $DATA_DIR \
|
||||
--port {{.Ports.BackendP2P}} \
|
||||
--http \
|
||||
--http.addr 127.0.0.1 \
|
||||
--http.port {{.Ports.BackendHttp}} \
|
||||
--http.api eth,net,web3,debug,txpool \
|
||||
--http.vhosts '*' \
|
||||
--http.corsdomain '*' \
|
||||
--ws \
|
||||
--ws.addr 127.0.0.1 \
|
||||
--ws.port {{.Ports.BackendRPC}} \
|
||||
--ws.api eth,net,web3,debug,txpool \
|
||||
--ws.origins '*' \
|
||||
--gcmode archive \
|
||||
--cache.gc 0 \
|
||||
--cache.trie 30 \
|
||||
--syncmode full \
|
||||
--maxpeers 100 \
|
||||
--rpc.allow-unprotected-txs \
|
||||
--txlookuplimit 0 \
|
||||
--cache 8000 \
|
||||
--ipcdisable \
|
||||
--nat none
|
||||
|
||||
{{end}}
|
||||
@@ -26,6 +26,7 @@ type Backend struct {
|
||||
ExtractCommand string `json:"extract_command"`
|
||||
ExcludeFiles []string `json:"exclude_files"`
|
||||
ExecCommandTemplate string `json:"exec_command_template"`
|
||||
ExecScript string `json:"exec_script"`
|
||||
LogrotateFilesTemplate string `json:"logrotate_files_template"`
|
||||
PostinstScriptTemplate string `json:"postinst_script_template"`
|
||||
ServiceType string `json:"service_type"`
|
||||
@@ -280,11 +281,15 @@ func GeneratePackageDefinitions(config *Config, templateDir, outputDir string) e
|
||||
}
|
||||
|
||||
if !isEmpty(config, "backend") {
|
||||
err = writeBackendServerConfigFile(config, outputDir)
|
||||
if err == nil {
|
||||
err = writeBackendClientConfigFile(config, outputDir)
|
||||
if err := writeBackendServerConfigFile(config, outputDir); err != nil {
|
||||
return err
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
if err := writeBackendClientConfigFile(config, outputDir); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := writeBackendExecScript(config, outputDir); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -354,3 +359,24 @@ func writeBackendClientConfigFile(config *Config, outputDir string) error {
|
||||
_, err = io.Copy(out, in)
|
||||
return err
|
||||
}
|
||||
|
||||
func writeBackendExecScript(config *Config, outputDir string) error {
|
||||
if config.Backend.ExecScript == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
out, err := os.OpenFile(filepath.Join(outputDir, "backend/exec.sh"), os.O_CREATE|os.O_WRONLY, 0777)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer out.Close()
|
||||
|
||||
in, err := os.Open(filepath.Join(outputDir, "backend/scripts", config.Backend.ExecScript))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer in.Close()
|
||||
|
||||
_, err = io.Copy(out, in)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user