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
42
cli/main.go
42
cli/main.go
|
@ -1,43 +1,21 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"strings"
|
||||
"os"
|
||||
|
||||
"github.com/CityOfZion/neo-go/pkg/network"
|
||||
"github.com/CityOfZion/neo-go/cli/server"
|
||||
"github.com/CityOfZion/neo-go/cli/smartcontract"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
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()
|
||||
ctl := cli.NewApp()
|
||||
ctl.Name = "neo-go"
|
||||
|
||||
opts := network.StartOpts{
|
||||
Seeds: parseSeeds(*seed),
|
||||
TCP: *tcp,
|
||||
RPC: *rpc,
|
||||
ctl.Commands = []cli.Command{
|
||||
server.NewCommand(),
|
||||
smartcontract.NewCommand(),
|
||||
}
|
||||
|
||||
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
|
||||
ctl.Run(os.Args)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue