-
Notifications
You must be signed in to change notification settings - Fork 92
/
factomd.go
75 lines (59 loc) · 2.04 KB
/
factomd.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright 2017 Factom Foundation
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package engine
import (
"fmt"
"os"
"runtime"
"strings"
"time"
"github.com/FactomProject/factomd/common/primitives"
"github.com/FactomProject/factomd/log"
"github.com/FactomProject/factomd/state"
)
var _ = fmt.Print
// winServiceMain is only invoked on Windows. It detects when btcd is running
// as a service and reacts accordingly.
//var winServiceMain func() (bool, error)
// Build sets the factomd build id using git's SHA
// $ go install -ldflags "-X github.com/FactomProject/factomd/engine.Build=`git rev-parse HEAD`"
// It also seems to need to have the previous binary deleted if recompiling to have this message show up if no code has changed.
// Since we are tracking code changes, then there is no need to delete the binary to use the latest message
var Build string
func Factomd(args []string) {
log.Print("//////////////////////// Copyright 2017 Factom Foundation")
log.Print("//////////////////////// Use of this source code is governed by the MIT")
log.Print("//////////////////////// license that can be found in the LICENSE file.")
log.Printf("Go compiler version: %s\n", runtime.Version())
log.Printf("Using build: %s\n", Build)
if !isCompilerVersionOK() {
for i := 0; i < 30; i++ {
log.Println("!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!")
}
time.Sleep(3 * time.Second)
os.Exit(1)
}
// Go Optimizations...
runtime.GOMAXPROCS(runtime.NumCPU())
state0 := new(state.State)
state0.SetLeaderTimestamp(primitives.NewTimestampFromMilliseconds(0))
fmt.Println("len(Args)", len(os.Args))
NetStart(state0,args)
}
func isCompilerVersionOK() bool {
goodenough := false
if strings.Contains(runtime.Version(), "1.5") {
goodenough = true
}
if strings.Contains(runtime.Version(), "1.6") {
goodenough = true
}
if strings.Contains(runtime.Version(), "1.7") {
goodenough = true
}
if strings.Contains(runtime.Version(), "1.8") {
goodenough = true
}
return goodenough
}