Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

Commit

Permalink
Redirect status output to stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
tdemin committed Oct 13, 2020
1 parent ef12b07 commit bf97e22
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions main.go
Expand Up @@ -20,7 +20,15 @@ import (
"github.com/yggdrasil-network/yggdrasil-go/src/crypto"
)

var version = "v0.1.3"
var (
programName = "syg_go"
version = "v0.1.3"
)

var (
stdout = log.New(os.Stdout, "", log.Flags())
stderr = log.New(os.Stderr, "", log.Flags())
)

func main() {
rxflag := flag.String("regex", "::", "regex to match addresses against")
Expand All @@ -31,31 +39,32 @@ func main() {
highAddressMode := flag.Bool("highaddr", false, "high address mining mode, excludes regex")
flag.Parse()
if *displayVersion {
println("syg_go", version)
println(programName, version)
// TODO: add license and author information
return
}

if *origCode {
log.Println("using unmodified Yggdrasil code")
stdout.Println("using unmodified Yggdrasil code")
addrForNodeID = address.AddrForNodeID
} else {
log.Println("using syg_go vendored code")
stdout.Println("using syg_go vendored code")
addrForNodeID = AddrForNodeID
}

regex, err := regexp.Compile(*rxflag)
if err != nil {
log.Printf("%v\n", err)
stderr.Printf("%v\n", err)
os.Exit(1)
}

newKeys := make(chan keySet, *threads)
var currentBest []byte

if !*highAddressMode {
log.Printf("starting mining for %v with %v threads\n", regex, *threads)
stdout.Printf("starting mining for %v with %v threads\n", regex, *threads)
} else {
log.Printf("starting mining higher addresses with %v threads\n", *threads)
stdout.Printf("starting mining higher addresses with %v threads\n", *threads)
}
for i := 0; i < *threads; i++ {
go doBoxKeys(newKeys)
Expand All @@ -71,7 +80,7 @@ func main() {
}
counter++
if counter%i == 0 {
log.Printf("reached %v iterations\n", counter)
stderr.Printf("reached %v iterations\n", counter)
}
}
} else {
Expand All @@ -83,7 +92,7 @@ func main() {
}
counter++
if counter%i == 0 {
log.Printf("reached %v iterations\n", counter)
stderr.Printf("reached %v iterations\n", counter)
}
}
}
Expand All @@ -97,7 +106,7 @@ type keySet struct {
}

func (k *keySet) print() {
log.Printf("priv: %s | pub: %s | nodeid: %s | ip: %s\n",
stdout.Printf("priv: %s | pub: %s | nodeid: %s | ip: %s\n",
hex.EncodeToString(k.priv[:]),
hex.EncodeToString(k.pub[:]),
hex.EncodeToString(k.id[:]),
Expand Down

0 comments on commit bf97e22

Please sign in to comment.