2016-06-15 19:50:35 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-06-20 14:47:10 +00:00
|
|
|
"flag"
|
2016-06-15 19:50:35 +00:00
|
|
|
"fmt"
|
2016-06-20 14:47:10 +00:00
|
|
|
"runtime"
|
2016-06-15 19:50:35 +00:00
|
|
|
|
2016-06-20 14:47:10 +00:00
|
|
|
"github.com/codegangsta/cli"
|
|
|
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/ethereum/go-ethereum/logger"
|
|
|
|
"github.com/ethereum/go-ethereum/logger/glog"
|
|
|
|
"github.com/ethereum/go-ethereum/node"
|
|
|
|
"github.com/ethereum/go-ethereum/params"
|
|
|
|
"github.com/ethereum/go-ethereum/release"
|
|
|
|
"github.com/ethereum/go-ethereum/rlp"
|
2016-06-15 19:50:35 +00:00
|
|
|
)
|
|
|
|
|
2016-06-20 14:47:10 +00:00
|
|
|
const (
|
|
|
|
clientIdentifier = "Geth" // Client identifier to advertise over the network
|
|
|
|
versionMajor = 1 // Major version component of the current release
|
|
|
|
versionMinor = 5 // Minor version component of the current release
|
|
|
|
versionPatch = 0 // Patch version component of the current release
|
|
|
|
versionMeta = "unstable" // Version metadata to append to the version string
|
|
|
|
|
|
|
|
versionOracle = "0xfa7b9770ca4cb04296cac84f37736d4041251cdf" // Ethereum address of the Geth release oracle
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
vString string // Combined textual representation of all the version components
|
|
|
|
rConfig release.Config // Structured version information and release oracle config
|
|
|
|
currentNode *node.Node
|
|
|
|
c *cli.Context
|
|
|
|
)
|
2016-06-15 19:50:35 +00:00
|
|
|
|
2016-06-20 15:21:45 +00:00
|
|
|
func main() {
|
|
|
|
|
|
|
|
// Placeholder for anything we want to run by default
|
|
|
|
fmt.Println("You are running statusgo!")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-06-21 14:35:43 +00:00
|
|
|
// MakeNode create a geth node entity
|
2016-06-20 15:21:45 +00:00
|
|
|
func MakeNode(datadir string) *node.Node {
|
2016-06-15 19:50:35 +00:00
|
|
|
|
2016-06-20 14:47:10 +00:00
|
|
|
set := flag.NewFlagSet("test", 0)
|
|
|
|
set.Bool("shh", true, "whisper")
|
|
|
|
set.Bool("noeth", true, "disable eth")
|
2016-06-20 15:21:45 +00:00
|
|
|
set.String("datadir", datadir, "data directory for geth")
|
2016-06-20 14:47:10 +00:00
|
|
|
c = cli.NewContext(nil, set, nil)
|
2016-06-15 19:50:35 +00:00
|
|
|
|
2016-06-20 14:47:10 +00:00
|
|
|
// Construct the textual version string from the individual components
|
|
|
|
vString = fmt.Sprintf("%d.%d.%d", versionMajor, versionMinor, versionPatch)
|
|
|
|
|
|
|
|
// Construct the version release oracle configuration
|
|
|
|
rConfig.Oracle = common.HexToAddress(versionOracle)
|
|
|
|
|
|
|
|
rConfig.Major = uint32(versionMajor)
|
|
|
|
rConfig.Minor = uint32(versionMinor)
|
|
|
|
rConfig.Patch = uint32(versionPatch)
|
|
|
|
|
|
|
|
currentNode = utils.MakeSystemNode(clientIdentifier, vString, rConfig, makeDefaultExtra(), c)
|
2016-06-20 15:21:45 +00:00
|
|
|
return currentNode
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-06-21 14:35:43 +00:00
|
|
|
// StartNode starts a geth node entity
|
2016-06-20 15:21:45 +00:00
|
|
|
func StartNode(currentNode *node.Node) {
|
|
|
|
utils.StartNode(currentNode)
|
|
|
|
currentNode.Wait()
|
2016-06-20 14:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func makeDefaultExtra() []byte {
|
|
|
|
var clientInfo = struct {
|
|
|
|
Version uint
|
|
|
|
Name string
|
|
|
|
GoVersion string
|
|
|
|
Os string
|
|
|
|
}{uint(versionMajor<<16 | versionMinor<<8 | versionPatch), clientIdentifier, runtime.Version(), runtime.GOOS}
|
|
|
|
extra, err := rlp.EncodeToBytes(clientInfo)
|
|
|
|
if err != nil {
|
|
|
|
glog.V(logger.Warn).Infoln("error setting canonical miner information:", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if uint64(len(extra)) > params.MaximumExtraDataSize.Uint64() {
|
|
|
|
glog.V(logger.Warn).Infoln("error setting canonical miner information: extra exceeds", params.MaximumExtraDataSize)
|
|
|
|
glog.V(logger.Debug).Infof("extra: %x\n", extra)
|
|
|
|
return nil
|
2016-06-15 19:50:35 +00:00
|
|
|
}
|
2016-06-20 14:47:10 +00:00
|
|
|
return extra
|
2016-06-15 19:50:35 +00:00
|
|
|
}
|