-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Reward Calculation Cli & UI (#1884)
* update & embed mainnet rules ; render mainnet rules in markdown in the terminal ; embed architectures * update architecture setting in reward calculation & validate skycoin address * update reward system UI * add subcommand to set up systemd services for the reward system UI & backend * make format check * fix systemd service generation * fix systemd service generation * fix typo * change reward calculation ; define two pools explicitly * fix output text * updates to reward UI for second pool * continue refactoring reward system UI * clean up reward system UI code ; remove no longer used display from skywire cli log st * add more survey statistics to reward system UI * update all deps in go.mod with GO111MODULE=on go get -u ./... * fix CI error ; fix dependency error * remove unused * improve sorting of statistics in reward system UI * update skycoin-service-discovery dependency
- Loading branch information
Showing
2,225 changed files
with
499,217 additions
and
178,681 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["amd64","arm64","386","arm","ppc64","riscv64","wasm","loong64","mips","mips64","mips64le","mipsle","ppc64le","s390x"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Package main cmd/gen/gen.go | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"log" | ||
"regexp" | ||
"runtime" | ||
|
||
"github.com/bitfield/script" | ||
cc "github.com/ivanpirog/coloredcobra" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
printJSON bool | ||
writeFile string | ||
) | ||
|
||
func init() { | ||
rootCmd.Flags().BoolVarP(&printJSON, "json", "j", false, "output json format") | ||
rootCmd.Flags().StringVarP(&writeFile, "output", "o", "", "write to the specified file (i.e. arches.json)") | ||
} | ||
|
||
// there is no other better way to get a list of architectures via a library or any simpler method at runtime | ||
// this file is executed by go generate from the root directory of the repository github.com/skycoin/skywire | ||
// go run cmd/gen/gen.go -j -o arches.json | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "gen", | ||
Short: "print architectures", | ||
Long: "print architectures", | ||
Run: func(_ *cobra.Command, _ []string) { | ||
if writeFile == "" { | ||
switch runtime.GOOS { | ||
case "windows": | ||
writeFile = `\\.\NUL` | ||
default: // For macOS and Linux | ||
writeFile = "/dev/null" | ||
} | ||
} | ||
if !printJSON { | ||
//equivalent bash one-liner: | ||
//go tool dist list | awk -F '/' '{print $NF}' | awk '{$1=$1};1' | sort | uniq | ||
_, err := script.Exec(`go tool dist list`).ReplaceRegexp(regexp.MustCompile(".*/"), "").Freq().ReplaceRegexp(regexp.MustCompile(`^\s*\d+\s+`), "").Tee().WriteFile(writeFile) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} else { | ||
rawOutput, err := script.Exec(`go tool dist list`).ReplaceRegexp(regexp.MustCompile(".*/"), "").Freq().ReplaceRegexp(regexp.MustCompile(`^\s*\d+\s+`), "").Slice() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
jsonData, err := json.Marshal(rawOutput) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
//equivalent bash one-liner: | ||
//go tool dist list | awk -F '/' '{print $NF}' | awk '{$1=$1};1' | sort | uniq | jq -R -s -c 'split("\n") | map(select(length > 0))' | tee arches.json | ||
_, err = script.Echo(string(jsonData) + "\n").Tee().WriteFile(writeFile) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
var helpflag bool | ||
rootCmd.SetUsageTemplate(help) | ||
rootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help menu") | ||
rootCmd.SetHelpCommand(&cobra.Command{Hidden: true}) | ||
rootCmd.PersistentFlags().MarkHidden("help") //nolint | ||
} | ||
|
||
func main() { | ||
cc.Init(&cc.Config{ | ||
RootCmd: rootCmd, | ||
Headings: cc.HiBlue + cc.Bold, | ||
Commands: cc.HiBlue + cc.Bold, | ||
CmdShortDescr: cc.HiBlue, | ||
Example: cc.HiBlue + cc.Italic, | ||
ExecName: cc.HiBlue + cc.Bold, | ||
Flags: cc.HiBlue + cc.Bold, | ||
FlagsDescr: cc.HiBlue, | ||
NoExtraNewlines: true, | ||
NoBottomNewline: true, | ||
}) | ||
rootCmd.Execute() //nolint | ||
} | ||
|
||
const help = "{{if .HasAvailableSubCommands}}{{end}} {{if gt (len .Aliases) 0}}\r\n\r\n" + | ||
"{{.NameAndAliases}}{{end}}{{if .HasAvailableSubCommands}}" + | ||
"Available Commands:{{range .Commands}} {{if and (ne .Name \"completion\") .IsAvailableCommand}}\r\n " + | ||
"{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}\r\n\r\n" + | ||
"Flags:\r\n" + | ||
"{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}\r\n\r\n" + | ||
"Global Flags:\r\n" + | ||
"{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}\r\n\r\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Package clireward cmd/skywire-cli/reward/rules.go | ||
package clireward | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
markdown "github.com/MichaelMure/go-term-markdown" | ||
"github.com/spf13/cobra" | ||
"golang.org/x/term" | ||
|
||
"github.com/skycoin/skywire" | ||
) | ||
|
||
func init() { | ||
rewardCmd.AddCommand(rulesCmd) | ||
} | ||
|
||
var rulesCmd = &cobra.Command{ | ||
Use: "rules", | ||
Short: "display the mainnet rules", | ||
Long: "display the mainnet rules", | ||
Run: func(_ *cobra.Command, _ []string) { | ||
terminalWidth, _, err := term.GetSize(int(os.Stdout.Fd())) | ||
if err != nil { | ||
terminalWidth = 80 | ||
} | ||
leftPad := 6 | ||
fmt.Printf("%s\n", markdown.Render(skywire.MainnetRules, terminalWidth, leftPad)) | ||
}, | ||
} |
Oops, something went wrong.