forked from cerc-io/plugeth
replaced several path.* with filepath.* which is platform independent
This commit is contained in:
parent
d82caa5ce3
commit
b79dd188d9
@ -22,9 +22,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
"github.com/ethereum/go-ethereum/common/docserver"
|
"github.com/ethereum/go-ethereum/common/docserver"
|
||||||
"github.com/ethereum/go-ethereum/common/natspec"
|
"github.com/ethereum/go-ethereum/common/natspec"
|
||||||
@ -209,7 +210,7 @@ func (self *jsre) interactive() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *jsre) withHistory(op func(*os.File)) {
|
func (self *jsre) withHistory(op func(*os.File)) {
|
||||||
hist, err := os.OpenFile(path.Join(self.ethereum.DataDir, "history"), os.O_RDWR|os.O_CREATE, os.ModePerm)
|
hist, err := os.OpenFile(filepath.Join(self.ethereum.DataDir, "history"), os.O_RDWR|os.O_CREATE, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("unable to open history file: %v\n", err)
|
fmt.Printf("unable to open history file: %v\n", err)
|
||||||
return
|
return
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -96,7 +95,7 @@ func testJEthRE(t *testing.T) (string, *testjethre, *eth.Ethereum) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
assetPath := path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist", "assets", "ext")
|
assetPath := filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist", "assets", "ext")
|
||||||
ds, err := docserver.New("/")
|
ds, err := docserver.New("/")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error creating DocServer: %v", err)
|
t.Errorf("Error creating DocServer: %v", err)
|
||||||
@ -361,7 +360,7 @@ func checkEvalJSON(t *testing.T, re *testjethre, expr, want string) error {
|
|||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_, file, line, _ := runtime.Caller(1)
|
_, file, line, _ := runtime.Caller(1)
|
||||||
file = path.Base(file)
|
file = filepath.Base(file)
|
||||||
fmt.Printf("\t%s:%d: %v\n", file, line, err)
|
fmt.Printf("\t%s:%d: %v\n", file, line, err)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -565,7 +564,7 @@ func upgradeDb(ctx *cli.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
filename := fmt.Sprintf("blockchain_%d_%s.chain", bcVersion, time.Now().Format("2006-01-02_15:04:05"))
|
filename := fmt.Sprintf("blockchain_%d_%s.chain", bcVersion, time.Now().Format("2006-01-02_15:04:05"))
|
||||||
exportFile := path.Join(ctx.GlobalString(utils.DataDirFlag.Name), filename)
|
exportFile := filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), filename)
|
||||||
|
|
||||||
err = utils.ExportChain(ethereum.ChainManager(), exportFile)
|
err = utils.ExportChain(ethereum.ChainManager(), exportFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -576,7 +575,7 @@ func upgradeDb(ctx *cli.Context) {
|
|||||||
ethereum.StateDb().Close()
|
ethereum.StateDb().Close()
|
||||||
ethereum.ExtraDb().Close()
|
ethereum.ExtraDb().Close()
|
||||||
|
|
||||||
os.RemoveAll(path.Join(ctx.GlobalString(utils.DataDirFlag.Name), "blockchain"))
|
os.RemoveAll(filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), "blockchain"))
|
||||||
|
|
||||||
ethereum, err = eth.New(cfg)
|
ethereum, err = eth.New(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -27,11 +27,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/big"
|
"math/big"
|
||||||
"path"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
@ -79,7 +80,7 @@ type Gui struct {
|
|||||||
|
|
||||||
// Create GUI, but doesn't start it
|
// Create GUI, but doesn't start it
|
||||||
func NewWindow(ethereum *eth.Ethereum) *Gui {
|
func NewWindow(ethereum *eth.Ethereum) *Gui {
|
||||||
db, err := ethdb.NewLDBDatabase(path.Join(ethereum.DataDir, "tx_database"))
|
db, err := ethdb.NewLDBDatabase(filepath.Join(ethereum.DataDir, "tx_database"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -92,7 +93,7 @@ func NewWindow(ethereum *eth.Ethereum) *Gui {
|
|||||||
plugins: make(map[string]plugin),
|
plugins: make(map[string]plugin),
|
||||||
serviceEvents: make(chan ServEv, 1),
|
serviceEvents: make(chan ServEv, 1),
|
||||||
}
|
}
|
||||||
data, _ := ioutil.ReadFile(path.Join(ethereum.DataDir, "plugins.json"))
|
data, _ := ioutil.ReadFile(filepath.Join(ethereum.DataDir, "plugins.json"))
|
||||||
json.Unmarshal(data, &gui.plugins)
|
json.Unmarshal(data, &gui.plugins)
|
||||||
|
|
||||||
return gui
|
return gui
|
||||||
|
@ -26,7 +26,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
@ -80,7 +79,7 @@ func (app *HtmlApplication) RootFolder() string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return path.Dir(common.WindonizePath(folder.RequestURI()))
|
return filepath.Dir(common.WindonizePath(folder.RequestURI()))
|
||||||
}
|
}
|
||||||
func (app *HtmlApplication) RecursiveFolders() []os.FileInfo {
|
func (app *HtmlApplication) RecursiveFolders() []os.FileInfo {
|
||||||
files, _ := ioutil.ReadDir(app.RootFolder())
|
files, _ := ioutil.ReadDir(app.RootFolder())
|
||||||
|
@ -22,7 +22,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path"
|
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
@ -110,7 +111,7 @@ func (ui *UiLib) ConnectToPeer(nodeURL string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ui *UiLib) AssetPath(p string) string {
|
func (ui *UiLib) AssetPath(p string) string {
|
||||||
return path.Join(ui.assetPath, p)
|
return filepath.Join(ui.assetPath, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *UiLib) Transact(params map[string]interface{}) (string, error) {
|
func (self *UiLib) Transact(params map[string]interface{}) (string, error) {
|
||||||
@ -218,7 +219,7 @@ func (self *UiLib) Messages(id int) *common.List {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *UiLib) ReadFile(p string) string {
|
func (self *UiLib) ReadFile(p string) string {
|
||||||
content, err := ioutil.ReadFile(self.AssetPath(path.Join("ext", p)))
|
content, err := ioutil.ReadFile(self.AssetPath(filepath.Join("ext", p)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
guilogger.Infoln("error reading file", p, ":", err)
|
guilogger.Infoln("error reading file", p, ":", err)
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,10 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
"github.com/ethereum/ethash"
|
"github.com/ethereum/ethash"
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
@ -55,7 +56,7 @@ OPTIONS:
|
|||||||
// NewApp creates an app with sane defaults.
|
// NewApp creates an app with sane defaults.
|
||||||
func NewApp(version, usage string) *cli.App {
|
func NewApp(version, usage string) *cli.App {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = path.Base(os.Args[0])
|
app.Name = filepath.Base(os.Args[0])
|
||||||
app.Author = ""
|
app.Author = ""
|
||||||
//app.Authors = nil
|
//app.Authors = nil
|
||||||
app.Email = ""
|
app.Email = ""
|
||||||
@ -319,17 +320,17 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
|
|||||||
func GetChain(ctx *cli.Context) (*core.ChainManager, common.Database, common.Database) {
|
func GetChain(ctx *cli.Context) (*core.ChainManager, common.Database, common.Database) {
|
||||||
dataDir := ctx.GlobalString(DataDirFlag.Name)
|
dataDir := ctx.GlobalString(DataDirFlag.Name)
|
||||||
|
|
||||||
blockDb, err := ethdb.NewLDBDatabase(path.Join(dataDir, "blockchain"))
|
blockDb, err := ethdb.NewLDBDatabase(filepath.Join(dataDir, "blockchain"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fatalf("Could not open database: %v", err)
|
Fatalf("Could not open database: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
stateDb, err := ethdb.NewLDBDatabase(path.Join(dataDir, "state"))
|
stateDb, err := ethdb.NewLDBDatabase(filepath.Join(dataDir, "state"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fatalf("Could not open database: %v", err)
|
Fatalf("Could not open database: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
extraDb, err := ethdb.NewLDBDatabase(path.Join(dataDir, "extra"))
|
extraDb, err := ethdb.NewLDBDatabase(filepath.Join(dataDir, "extra"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fatalf("Could not open database: %v", err)
|
Fatalf("Could not open database: %v", err)
|
||||||
}
|
}
|
||||||
@ -346,7 +347,7 @@ func GetChain(ctx *cli.Context) (*core.ChainManager, common.Database, common.Dat
|
|||||||
|
|
||||||
func GetAccountManager(ctx *cli.Context) *accounts.Manager {
|
func GetAccountManager(ctx *cli.Context) *accounts.Manager {
|
||||||
dataDir := ctx.GlobalString(DataDirFlag.Name)
|
dataDir := ctx.GlobalString(DataDirFlag.Name)
|
||||||
ks := crypto.NewKeyStorePassphrase(path.Join(dataDir, "keys"))
|
ks := crypto.NewKeyStorePassphrase(filepath.Join(dataDir, "keys"))
|
||||||
return accounts.NewManager(ks)
|
return accounts.NewManager(ks)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@ -130,10 +129,10 @@ func (sol *Solidity) Compile(source string) (contract *Contract, err error) {
|
|||||||
_, file := filepath.Split(matches[0])
|
_, file := filepath.Split(matches[0])
|
||||||
base := strings.Split(file, ".")[0]
|
base := strings.Split(file, ".")[0]
|
||||||
|
|
||||||
codeFile := path.Join(wd, base+".binary")
|
codeFile := filepath.Join(wd, base+".binary")
|
||||||
abiDefinitionFile := path.Join(wd, base+".abi")
|
abiDefinitionFile := filepath.Join(wd, base+".abi")
|
||||||
userDocFile := path.Join(wd, base+".docuser")
|
userDocFile := filepath.Join(wd, base+".docuser")
|
||||||
developerDocFile := path.Join(wd, base+".docdev")
|
developerDocFile := filepath.Join(wd, base+".docdev")
|
||||||
|
|
||||||
code, err := ioutil.ReadFile(codeFile)
|
code, err := ioutil.ReadFile(codeFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
@ -44,22 +43,22 @@ func FileExist(filePath string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func AbsolutePath(Datadir string, filename string) string {
|
func AbsolutePath(Datadir string, filename string) string {
|
||||||
if path.IsAbs(filename) {
|
if filepath.IsAbs(filename) {
|
||||||
return filename
|
return filename
|
||||||
}
|
}
|
||||||
return path.Join(Datadir, filename)
|
return filepath.Join(Datadir, filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DefaultAssetPath() string {
|
func DefaultAssetPath() string {
|
||||||
var assetPath string
|
var assetPath string
|
||||||
pwd, _ := os.Getwd()
|
pwd, _ := os.Getwd()
|
||||||
srcdir := path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist")
|
srcdir := filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist")
|
||||||
|
|
||||||
// If the current working directory is the go-ethereum dir
|
// If the current working directory is the go-ethereum dir
|
||||||
// assume a debug build and use the source directory as
|
// assume a debug build and use the source directory as
|
||||||
// asset directory.
|
// asset directory.
|
||||||
if pwd == srcdir {
|
if pwd == srcdir {
|
||||||
assetPath = path.Join(pwd, "assets")
|
assetPath = filepath.Join(pwd, "assets")
|
||||||
} else {
|
} else {
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "darwin":
|
case "darwin":
|
||||||
@ -67,9 +66,9 @@ func DefaultAssetPath() string {
|
|||||||
exedir, _ := osext.ExecutableFolder()
|
exedir, _ := osext.ExecutableFolder()
|
||||||
assetPath = filepath.Join(exedir, "..", "Resources")
|
assetPath = filepath.Join(exedir, "..", "Resources")
|
||||||
case "linux":
|
case "linux":
|
||||||
assetPath = path.Join("usr", "share", "mist")
|
assetPath = filepath.Join("usr", "share", "mist")
|
||||||
case "windows":
|
case "windows":
|
||||||
assetPath = path.Join(".", "assets")
|
assetPath = filepath.Join(".", "assets")
|
||||||
default:
|
default:
|
||||||
assetPath = "."
|
assetPath = "."
|
||||||
}
|
}
|
||||||
@ -78,7 +77,7 @@ func DefaultAssetPath() string {
|
|||||||
// Check if the assetPath exists. If not, try the source directory
|
// Check if the assetPath exists. If not, try the source directory
|
||||||
// This happens when binary is run from outside cmd/mist directory
|
// This happens when binary is run from outside cmd/mist directory
|
||||||
if _, err := os.Stat(assetPath); os.IsNotExist(err) {
|
if _, err := os.Stat(assetPath); os.IsNotExist(err) {
|
||||||
assetPath = path.Join(srcdir, "assets")
|
assetPath = filepath.Join(srcdir, "assets")
|
||||||
}
|
}
|
||||||
|
|
||||||
return assetPath
|
return assetPath
|
||||||
@ -87,11 +86,11 @@ func DefaultAssetPath() string {
|
|||||||
func DefaultDataDir() string {
|
func DefaultDataDir() string {
|
||||||
usr, _ := user.Current()
|
usr, _ := user.Current()
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
return path.Join(usr.HomeDir, "Library", "Ethereum")
|
return filepath.Join(usr.HomeDir, "Library", "Ethereum")
|
||||||
} else if runtime.GOOS == "windows" {
|
} else if runtime.GOOS == "windows" {
|
||||||
return path.Join(usr.HomeDir, "AppData", "Roaming", "Ethereum")
|
return filepath.Join(usr.HomeDir, "AppData", "Roaming", "Ethereum")
|
||||||
} else {
|
} else {
|
||||||
return path.Join(usr.HomeDir, ".ethereum")
|
return filepath.Join(usr.HomeDir, ".ethereum")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,11 +4,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
@ -94,7 +95,7 @@ func testChain(chainB types.Blocks, bman *BlockProcessor) (*big.Int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func loadChain(fn string, t *testing.T) (types.Blocks, error) {
|
func loadChain(fn string, t *testing.T) (types.Blocks, error) {
|
||||||
fh, err := os.OpenFile(path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "_data", fn), os.O_RDONLY, os.ModePerm)
|
fh, err := os.OpenFile(filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "_data", fn), os.O_RDONLY, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
|
|
||||||
"code.google.com/p/go-uuid/uuid"
|
"code.google.com/p/go-uuid/uuid"
|
||||||
"github.com/ethereum/go-ethereum/crypto/randentropy"
|
"github.com/ethereum/go-ethereum/crypto/randentropy"
|
||||||
@ -163,7 +163,7 @@ func (ks keyStorePassphrase) DeleteKey(keyAddr []byte, auth string) (err error)
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
keyDirPath := path.Join(ks.keysDirPath, hex.EncodeToString(keyAddr))
|
keyDirPath := filepath.Join(ks.keysDirPath, hex.EncodeToString(keyAddr))
|
||||||
return os.RemoveAll(keyDirPath)
|
return os.RemoveAll(keyDirPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: rename to KeyStore when replacing existing KeyStore
|
// TODO: rename to KeyStore when replacing existing KeyStore
|
||||||
@ -91,20 +91,20 @@ func (ks keyStorePlain) StoreKey(key *Key, auth string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ks keyStorePlain) DeleteKey(keyAddr []byte, auth string) (err error) {
|
func (ks keyStorePlain) DeleteKey(keyAddr []byte, auth string) (err error) {
|
||||||
keyDirPath := path.Join(ks.keysDirPath, hex.EncodeToString(keyAddr))
|
keyDirPath := filepath.Join(ks.keysDirPath, hex.EncodeToString(keyAddr))
|
||||||
err = os.RemoveAll(keyDirPath)
|
err = os.RemoveAll(keyDirPath)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetKeyFile(keysDirPath string, keyAddr []byte) (fileContent []byte, err error) {
|
func GetKeyFile(keysDirPath string, keyAddr []byte) (fileContent []byte, err error) {
|
||||||
fileName := hex.EncodeToString(keyAddr)
|
fileName := hex.EncodeToString(keyAddr)
|
||||||
return ioutil.ReadFile(path.Join(keysDirPath, fileName, fileName))
|
return ioutil.ReadFile(filepath.Join(keysDirPath, fileName, fileName))
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteKeyFile(addr []byte, keysDirPath string, content []byte) (err error) {
|
func WriteKeyFile(addr []byte, keysDirPath string, content []byte) (err error) {
|
||||||
addrHex := hex.EncodeToString(addr)
|
addrHex := hex.EncodeToString(addr)
|
||||||
keyDirPath := path.Join(keysDirPath, addrHex)
|
keyDirPath := filepath.Join(keysDirPath, addrHex)
|
||||||
keyFilePath := path.Join(keyDirPath, addrHex)
|
keyFilePath := filepath.Join(keyDirPath, addrHex)
|
||||||
err = os.MkdirAll(keyDirPath, 0700) // read, write and dir search for user
|
err = os.MkdirAll(keyDirPath, 0700) // read, write and dir search for user
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -145,7 +144,7 @@ func (cfg *Config) nodeKey() (*ecdsa.PrivateKey, error) {
|
|||||||
return cfg.NodeKey, nil
|
return cfg.NodeKey, nil
|
||||||
}
|
}
|
||||||
// use persistent key if present
|
// use persistent key if present
|
||||||
keyfile := path.Join(cfg.DataDir, "nodekey")
|
keyfile := filepath.Join(cfg.DataDir, "nodekey")
|
||||||
key, err := crypto.LoadECDSA(keyfile)
|
key, err := crypto.LoadECDSA(keyfile)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return key, nil
|
return key, nil
|
||||||
@ -214,25 +213,25 @@ func New(config *Config) (*Ethereum, error) {
|
|||||||
if newdb == nil {
|
if newdb == nil {
|
||||||
newdb = func(path string) (common.Database, error) { return ethdb.NewLDBDatabase(path) }
|
newdb = func(path string) (common.Database, error) { return ethdb.NewLDBDatabase(path) }
|
||||||
}
|
}
|
||||||
blockDb, err := newdb(path.Join(config.DataDir, "blockchain"))
|
blockDb, err := newdb(filepath.Join(config.DataDir, "blockchain"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("blockchain db err: %v", err)
|
return nil, fmt.Errorf("blockchain db err: %v", err)
|
||||||
}
|
}
|
||||||
stateDb, err := newdb(path.Join(config.DataDir, "state"))
|
stateDb, err := newdb(filepath.Join(config.DataDir, "state"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("state db err: %v", err)
|
return nil, fmt.Errorf("state db err: %v", err)
|
||||||
}
|
}
|
||||||
extraDb, err := newdb(path.Join(config.DataDir, "extra"))
|
extraDb, err := newdb(filepath.Join(config.DataDir, "extra"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("extra db err: %v", err)
|
return nil, fmt.Errorf("extra db err: %v", err)
|
||||||
}
|
}
|
||||||
nodeDb := path.Join(config.DataDir, "nodes")
|
nodeDb := filepath.Join(config.DataDir, "nodes")
|
||||||
|
|
||||||
// Perform database sanity checks
|
// Perform database sanity checks
|
||||||
d, _ := blockDb.Get([]byte("ProtocolVersion"))
|
d, _ := blockDb.Get([]byte("ProtocolVersion"))
|
||||||
protov := int(common.NewValue(d).Uint())
|
protov := int(common.NewValue(d).Uint())
|
||||||
if protov != config.ProtocolVersion && protov != 0 {
|
if protov != config.ProtocolVersion && protov != 0 {
|
||||||
path := path.Join(config.DataDir, "blockchain")
|
path := filepath.Join(config.DataDir, "blockchain")
|
||||||
return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, config.ProtocolVersion, path)
|
return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, config.ProtocolVersion, path)
|
||||||
}
|
}
|
||||||
saveProtocolVersion(blockDb, config.ProtocolVersion)
|
saveProtocolVersion(blockDb, config.ProtocolVersion)
|
||||||
|
@ -2,13 +2,14 @@ package ethdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newDb() *LDBDatabase {
|
func newDb() *LDBDatabase {
|
||||||
file := path.Join("/", "tmp", "ldbtesttmpfile")
|
file := filepath.Join("/", "tmp", "ldbtesttmpfile")
|
||||||
if common.FileExist(file) {
|
if common.FileExist(file) {
|
||||||
os.RemoveAll(file)
|
os.RemoveAll(file)
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ func main() {
|
|||||||
m := make(map[string]setting)
|
m := make(map[string]setting)
|
||||||
json.Unmarshal(content, &m)
|
json.Unmarshal(content, &m)
|
||||||
|
|
||||||
filepath := path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "params", os.Args[2])
|
filepath := filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "params", os.Args[2])
|
||||||
output, err := os.OpenFile(filepath, os.O_RDWR|os.O_CREATE, os.ModePerm /*0777*/)
|
output, err := os.OpenFile(filepath, os.O_RDWR|os.O_CREATE, os.ModePerm /*0777*/)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal("error opening file for writing %v\n", err)
|
fatal("error opening file for writing %v\n", err)
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
logpkg "log"
|
logpkg "log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
@ -18,6 +17,7 @@ import (
|
|||||||
|
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/logger"
|
"github.com/ethereum/go-ethereum/logger"
|
||||||
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -88,7 +88,7 @@ func (test *udpTest) waitPacketOut(validate interface{}) error {
|
|||||||
func (test *udpTest) errorf(format string, args ...interface{}) error {
|
func (test *udpTest) errorf(format string, args ...interface{}) error {
|
||||||
_, file, line, ok := runtime.Caller(2) // errorf + waitPacketOut
|
_, file, line, ok := runtime.Caller(2) // errorf + waitPacketOut
|
||||||
if ok {
|
if ok {
|
||||||
file = path.Base(file)
|
file = filepath.Base(file)
|
||||||
} else {
|
} else {
|
||||||
file = "???"
|
file = "???"
|
||||||
line = 1
|
line = 1
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package tests
|
package tests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
@ -99,7 +99,7 @@ func runBlockTest(name string, test *BlockTest, t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testEthConfig() *eth.Config {
|
func testEthConfig() *eth.Config {
|
||||||
ks := crypto.NewKeyStorePassphrase(path.Join(common.DefaultDataDir(), "keys"))
|
ks := crypto.NewKeyStorePassphrase(filepath.Join(common.DefaultDataDir(), "keys"))
|
||||||
|
|
||||||
return ð.Config{
|
return ð.Config{
|
||||||
DataDir: common.DefaultDataDir(),
|
DataDir: common.DefaultDataDir(),
|
||||||
|
@ -26,13 +26,13 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -144,7 +144,7 @@ func getFiles(out chan<- string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ext := path.Ext(line)
|
ext := filepath.Ext(line)
|
||||||
for _, wantExt := range extensions {
|
for _, wantExt := range extensions {
|
||||||
if ext == wantExt {
|
if ext == wantExt {
|
||||||
goto send
|
goto send
|
||||||
|
Loading…
Reference in New Issue
Block a user