forked from TrueCloudLab/neoneo-go
Simplify CLI build process (#7)
This commit is contained in:
parent
a95ce31176
commit
36335e587f
4 changed files with 22 additions and 9 deletions
43
cli/main.go
Normal file
43
cli/main.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"strings"
|
||||
|
||||
"github.com/anthdm/neo-go/pkg/network"
|
||||
)
|
||||
|
||||
var (
|
||||
tcp = flag.Int("tcp", 3000, "port TCP listener will listen on.")
|
||||
seed = flag.String("seed", "", "initial seed servers.")
|
||||
net = flag.Int("net", 56753, "the mode the server will operate in.")
|
||||
rpc = flag.Int("rpc", 0, "let this server also respond to rpc calls on this port")
|
||||
)
|
||||
|
||||
// Simple dirty and quick bootstrapping for the sake of development.
|
||||
// e.g run 2 nodes:
|
||||
// neoserver -tcp :4000
|
||||
// neoserver -tcp :3000 -seed 127.0.0.1:4000
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
opts := network.StartOpts{
|
||||
Seeds: parseSeeds(*seed),
|
||||
TCP: *tcp,
|
||||
RPC: *rpc,
|
||||
}
|
||||
|
||||
s := network.NewServer(network.NetMode(*net))
|
||||
s.Start(opts)
|
||||
}
|
||||
|
||||
func parseSeeds(s string) []string {
|
||||
if len(s) == 0 {
|
||||
return nil
|
||||
}
|
||||
seeds := strings.Split(s, ",")
|
||||
if len(seeds) == 0 {
|
||||
return nil
|
||||
}
|
||||
return seeds
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue