neoneo-go/cmd/neoserver/main.go

33 lines
691 B
Go
Raw Normal View History

2018-01-26 18:04:13 +00:00
package main
import (
"flag"
"strings"
"github.com/anthdm/neo-go/pkg/network"
)
var (
port = flag.String("port", ":3000", "port the TCP listener will listen on.")
seed = flag.String("seed", "", "initial seed servers.")
2018-01-26 20:39:34 +00:00
net = flag.Int("net", 56753, "the mode the server will operate in.")
2018-01-26 18:04:13 +00:00
)
// Simple dirty and quick bootstrapping for the sake of development.
// e.g run 2 nodes:
// neoserver -port :4000
// neoserver -port :3000 -seed 127.0.0.1:4000
func main() {
flag.Parse()
2018-01-26 20:39:34 +00:00
s := network.NewServer(network.NetMode(*net))
2018-01-26 18:04:13 +00:00
seeds := strings.Split(*seed, ",")
if len(seeds) == 0 {
seeds = []string{*seed}
}
if *seed == "" {
seeds = []string{}
}
s.Start(*port, seeds)
}