Skip to content

Commit 404b3ab

Browse files
authored
Create new config.sh to read proper values from the user about provider, gas multiplier and buffer. (#67)
Signed-off-by: Ashish Mishra <[email protected]>
1 parent 35e1545 commit 404b3ab

File tree

3 files changed

+39
-12
lines changed

3 files changed

+39
-12
lines changed

Makefile

+6-11
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,11 @@ fetch_bindings:
1414
install_razor:
1515
@echo "Installing razor node...."
1616
${GO} build -o ./build/bin/razor main.go
17-
@echo "Razor node installed. \n"
17+
@echo "Razor node installed."
18+
@echo ""
1819

1920
set_config:
20-
@echo "Enter provider: "; \
21-
read PROVIDER; \
22-
echo "Enter gas multiplier value: "; \
23-
read GAS_MULTIPLIER; \
24-
echo "Enter buffer percent: "; \
25-
read BUFFER_PERCENT; \
26-
echo "\n"; \
27-
echo "Setting initial config..."; \
28-
${RAZOR} setconfig -p $${PROVIDER} -g $${GAS_MULTIPLIER} -b $${BUFFER_PERCENT}
29-
@echo "Setup done"
21+
@echo "Setup initial config"
22+
@${SHELL} config.sh
23+
@echo ""
24+
@echo "Razor node is set up and ready to use"

cmd/setconfig.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package cmd
22

33
import (
4+
log "github.com/sirupsen/logrus"
45
"github.com/spf13/cobra"
56
"github.com/spf13/viper"
6-
"log"
77
"razor/utils"
88
)
99

@@ -26,6 +26,12 @@ Setting the gas multiplier value enables the CLI to multiply the gas with that v
2626
if bufferPercent != 0 {
2727
viper.Set("buffer", bufferPercent)
2828
}
29+
if provider == "" && gasMultiplier == -1 && bufferPercent == 0 {
30+
viper.Set("provider", "http://127.0.0.1:8545")
31+
viper.Set("gasmultiplier", 1.0)
32+
viper.Set("buffer", 30)
33+
log.Info("Config values set to default. Use setconfig to modify the values.")
34+
}
2935
path := utils.GetDefaultPath() + "/razor.yaml"
3036
err := viper.WriteConfigAs(path)
3137
if err != nil {

config.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
set -e -o pipefail
4+
5+
BIN_DIR=./build/bin
6+
RAZOR=${BIN_DIR}/razor
7+
8+
read -rp "Provider: (http://127.0.0.1:8545) " PROVIDER
9+
if [ -z "$PROVIDER" ];
10+
then
11+
PROVIDER="http://127.0.0.1:8545"
12+
fi
13+
14+
read -rp "Gas Multiplier: (1.0) " GASMULTIPLIER
15+
if [ -z "$GASMULTIPLIER" ];
16+
then
17+
GASMULTIPLIER=1.0
18+
fi
19+
20+
read -rp "Buffer Percent: (20) " BUFFER
21+
if [ -z "$BUFFER" ];
22+
then
23+
BUFFER=20
24+
fi
25+
26+
$RAZOR setconfig -p $PROVIDER -b $BUFFER -g $GASMULTIPLIER

0 commit comments

Comments
 (0)