re-name functions, modify inputs
This commit is contained in:
parent
9272538432
commit
f20608eaa7
|
@ -22,6 +22,8 @@ var (
|
|||
// createAccount creates an internal geth account
|
||||
func createAccount(password, keydir string) (string, string, error) {
|
||||
|
||||
if currentNode != nil {
|
||||
|
||||
var sync *[]node.Service
|
||||
w := true
|
||||
accman := accounts.NewManager(keydir, scryptN, scryptP, sync)
|
||||
|
@ -48,6 +50,10 @@ func createAccount(password, keydir string) (string, string, error) {
|
|||
|
||||
}
|
||||
|
||||
return "", "", errors.New("No running node detected for account creation")
|
||||
|
||||
}
|
||||
|
||||
// unlockAccount unlocks an existing account for a certain duration and
|
||||
// inject the account as a whisper identity if the account was created as
|
||||
// a whisper enabled account
|
||||
|
@ -80,7 +86,7 @@ func createAndStartNode(datadir string) error {
|
|||
|
||||
currentNode = MakeNode(datadir)
|
||||
if currentNode != nil {
|
||||
StartNode(currentNode)
|
||||
RunNode(currentNode)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"os"
|
||||
)
|
||||
|
||||
//export doCreateAccount
|
||||
func doCreateAccount(password, keydir *C.char) *C.char {
|
||||
//export CreateAccount
|
||||
func CreateAccount(password, keydir *C.char) *C.char {
|
||||
// This is equivalent to creating an account from the command line,
|
||||
// just modified to handle the function arg passing
|
||||
address, pubKey, err := createAccount(C.GoString(password), C.GoString(keydir))
|
||||
|
@ -25,8 +25,16 @@ func doCreateAccount(password, keydir *C.char) *C.char {
|
|||
|
||||
}
|
||||
|
||||
//export doUnlockAccount
|
||||
func doUnlockAccount(address, password *C.char, seconds int) *C.char {
|
||||
//export Login
|
||||
func Login(address, password *C.char) *C.char {
|
||||
// Equivalent to unlocking an account briefly, to inject a whisper identity,
|
||||
// then locking the account again
|
||||
out := UnlockAccount(address, password, 5)
|
||||
return out
|
||||
}
|
||||
|
||||
//export UnlockAccount
|
||||
func UnlockAccount(address, password *C.char, seconds int) *C.char {
|
||||
// This is equivalent to unlocking an account from the command line,
|
||||
// just modified to unlock the account for the currently running geth node
|
||||
// based on the provided arguments
|
||||
|
@ -41,8 +49,8 @@ func doUnlockAccount(address, password *C.char, seconds int) *C.char {
|
|||
return C.CString(string(outBytes))
|
||||
}
|
||||
|
||||
//export doStartNode
|
||||
func doStartNode(datadir *C.char) *C.char {
|
||||
//export StartNode
|
||||
func StartNode(datadir *C.char) *C.char {
|
||||
// This starts a geth node with the given datadir
|
||||
err := createAndStartNode(C.GoString(datadir))
|
||||
out := JSONError{
|
||||
|
|
12
src/main.go
12
src/main.go
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
|
@ -27,11 +28,12 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
vString string // Combined textual representation of the version components
|
||||
vString string // Combined textual representation of the version
|
||||
rConfig release.Config // Structured version information and release oracle config
|
||||
currentNode *node.Node
|
||||
c *cli.Context
|
||||
accountSync []node.Service
|
||||
currentNode *node.Node // currently running geth node
|
||||
c *cli.Context // the CLI context used to start the geth node
|
||||
accountSync []node.Service // the object used to sync accounts between geth services
|
||||
MyTransactions chan TxRequest
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -66,7 +68,7 @@ func MakeNode(datadir string) *node.Node {
|
|||
}
|
||||
|
||||
// StartNode starts a geth node entity
|
||||
func StartNode(nodeIn *node.Node) {
|
||||
func RunNode(nodeIn *node.Node) {
|
||||
utils.StartNode(nodeIn)
|
||||
nodeIn.Wait()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue