-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
60 lines (53 loc) · 1.46 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"fmt"
"math/rand"
"minaxnt/miner"
"minaxnt/util"
"os"
"os/signal"
"runtime"
"syscall"
"time"
"github.com/mattn/go-colorable"
log "github.com/sirupsen/logrus"
flag "github.com/spf13/pflag"
)
var (
address = flag.StringP("address", "a", "", "Axentro address to receive rewards")
node = flag.StringP("node", "n", "http://mainnet.axentro.io", "Node URL to mine against")
process = flag.IntP("process", "p", 1, "Number of core(s) to use")
debug = flag.Bool("debug", false, "Set log level to debug")
minerName = "MinAXNT"
// Version of MinAXNT
Version = "v0.0.0"
)
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
rand.Seed(time.Now().Unix())
log.SetOutput(colorable.NewColorableStdout())
log.SetFormatter(&log.TextFormatter{
DisableColors: false,
DisableLevelTruncation: true,
ForceColors: true,
FullTimestamp: true,
})
flag.Parse()
}
func main() {
if *debug {
log.SetLevel(log.DebugLevel)
}
if !util.IsValidAddress(*address) {
flag.Usage()
log.Fatal("Wallet address is missing or is not valid!")
}
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
client := miner.NewClient(fmt.Sprintf("%s - %s", minerName, Version), *node, *address, *process)
util.Welcome(client)
client.Start()
<-interrupt
log.Warnf("%s is stopped", client.ClientName)
time.Sleep(1 * time.Second) // A chance for remote close signal to be send
}