-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
47 lines (36 loc) · 981 Bytes
/
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
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"strconv"
"log"
"github.com/grrrben/glog"
)
var bc *Blockchain
var nodes *Nodes
var nodePort uint16
var nodeName *string
const zerohash = "0000000000000000000000000000000000000000000000000000000000000000"
func main() {
prt := flag.String("p", "8000", "Port on which the app will run, defaults to 8000")
nodeName = flag.String("name", "Node_X", "Set a name for the node")
flag.Parse()
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
log.Fatalf("Could not set a logdir. Msg %s", err)
}
glog.SetLogFile(fmt.Sprintf("%s/log/blockchain.log", dir))
glog.SetLogLevel(glog.Log_level_info)
u, err := strconv.ParseUint(*prt, 10, 16) // always gives an uint64...
if err != nil {
glog.Errorf("Unable to cast Prt to uint: %s", err)
}
// different Nodes can have different ports,
// used to connect multiple Nodes in debug.
nodePort = uint16(u)
a := App{}
a.Initialize()
a.Run()
}