node object with start function
This commit is contained in:
parent
1422ee9cb2
commit
7399ea5b83
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts"
|
||||
|
@ -28,3 +29,15 @@ func createAccount(password, keydir string) error {
|
|||
return nil
|
||||
|
||||
}
|
||||
|
||||
func createAndStartNode(datadir string) error {
|
||||
|
||||
currentNode := MakeNode(datadir)
|
||||
if currentNode != nil {
|
||||
StartNode(currentNode)
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.New("Could not create the in-memory node object")
|
||||
|
||||
}
|
||||
|
|
|
@ -16,3 +16,14 @@ func doCreateAccount(password, keydir *C.char) C.int {
|
|||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// export doStartNode
|
||||
func doStartNode(datadir *C.char) C.int {
|
||||
// This starts a geth node with the given datadir
|
||||
if err := createAndStartNode(C.GoString(datadir)); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
return -1
|
||||
}
|
||||
return 0
|
||||
|
||||
}
|
||||
|
|
23
src/main.go
23
src/main.go
|
@ -33,18 +33,21 @@ var (
|
|||
c *cli.Context
|
||||
)
|
||||
|
||||
func init() {
|
||||
func main() {
|
||||
|
||||
// Placeholder for anything we want to run by default
|
||||
fmt.Println("You are running statusgo!")
|
||||
|
||||
}
|
||||
|
||||
func MakeNode(datadir string) *node.Node {
|
||||
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
set.Bool("shh", true, "whisper")
|
||||
set.Bool("noeth", true, "disable eth")
|
||||
set.String("datadir", ".ethereum", "data directory for geth")
|
||||
set.String("datadir", datadir, "data directory for geth")
|
||||
c = cli.NewContext(nil, set, nil)
|
||||
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
// Construct the textual version string from the individual components
|
||||
vString = fmt.Sprintf("%d.%d.%d", versionMajor, versionMinor, versionPatch)
|
||||
|
||||
|
@ -56,7 +59,13 @@ func main() {
|
|||
rConfig.Patch = uint32(versionPatch)
|
||||
|
||||
currentNode = utils.MakeSystemNode(clientIdentifier, vString, rConfig, makeDefaultExtra(), c)
|
||||
fmt.Println(currentNode)
|
||||
return currentNode
|
||||
|
||||
}
|
||||
|
||||
func StartNode(currentNode *node.Node) {
|
||||
utils.StartNode(currentNode)
|
||||
currentNode.Wait()
|
||||
}
|
||||
|
||||
func makeDefaultExtra() []byte {
|
||||
|
|
Loading…
Reference in New Issue