VM draft + cli setup (#20)
* updated readme * added basic cmd. * added seperate folders for cmd packages. * Fix netmodes in test + reverse bigint bytes * glide get deps
This commit is contained in:
parent
b6d8271b8d
commit
f7d57e4e49
18 changed files with 861 additions and 49 deletions
56
cli/server/server.go
Normal file
56
cli/server/server.go
Normal file
|
@ -0,0 +1,56 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/CityOfZion/neo-go/pkg/network"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
// NewCommand creates a new Node command
|
||||
func NewCommand() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "node",
|
||||
Usage: "start a NEO node",
|
||||
Action: startServer,
|
||||
Flags: []cli.Flag{
|
||||
cli.IntFlag{Name: "tcp"},
|
||||
cli.IntFlag{Name: "rpc"},
|
||||
cli.StringFlag{Name: "seed"},
|
||||
cli.BoolFlag{Name: "privnet, p"},
|
||||
cli.BoolFlag{Name: "mainnet, m"},
|
||||
cli.BoolFlag{Name: "testnet, t"},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func startServer(ctx *cli.Context) error {
|
||||
opts := network.StartOpts{
|
||||
Seeds: parseSeeds(ctx.String("seed")),
|
||||
TCP: ctx.Int("tcp"),
|
||||
RPC: ctx.Int("rpc"),
|
||||
}
|
||||
|
||||
net := network.ModePrivNet
|
||||
if ctx.Bool("testnet") {
|
||||
net = network.ModeTestNet
|
||||
}
|
||||
if ctx.Bool("mainnet") {
|
||||
net = network.ModeMainNet
|
||||
}
|
||||
|
||||
s := network.NewServer(net)
|
||||
s.Start(opts)
|
||||
return nil
|
||||
}
|
||||
|
||||
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