forked from cerc-io/plugeth
swarm/api: add bzz prefix to swarm directory
This commit is contained in:
parent
cc0064b267
commit
ef50e01c5e
@ -59,9 +59,8 @@ type Config struct {
|
|||||||
// config is agnostic to where private key is coming from
|
// config is agnostic to where private key is coming from
|
||||||
// so managing accounts is outside swarm and left to wrappers
|
// so managing accounts is outside swarm and left to wrappers
|
||||||
func NewConfig(path string, contract common.Address, prvKey *ecdsa.PrivateKey) (self *Config, err error) {
|
func NewConfig(path string, contract common.Address, prvKey *ecdsa.PrivateKey) (self *Config, err error) {
|
||||||
|
|
||||||
address := crypto.PubkeyToAddress(prvKey.PublicKey) // default beneficiary address
|
address := crypto.PubkeyToAddress(prvKey.PublicKey) // default beneficiary address
|
||||||
dirpath := filepath.Join(path, common.Bytes2Hex(address.Bytes()))
|
dirpath := filepath.Join(path, "bzz-"+common.Bytes2Hex(address.Bytes()))
|
||||||
err = os.MkdirAll(dirpath, os.ModePerm)
|
err = os.MkdirAll(dirpath, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -30,14 +30,14 @@ import (
|
|||||||
var (
|
var (
|
||||||
hexprvkey = "65138b2aa745041b372153550584587da326ab440576b2a1191dd95cee30039c"
|
hexprvkey = "65138b2aa745041b372153550584587da326ab440576b2a1191dd95cee30039c"
|
||||||
defaultConfig = `{
|
defaultConfig = `{
|
||||||
"ChunkDbPath": "` + filepath.Join("TMPDIR", "0d2f62485607cf38d9d795d93682a517661e513e", "chunks") + `",
|
"ChunkDbPath": "` + filepath.Join("TMPDIR", "chunks") + `",
|
||||||
"DbCapacity": 5000000,
|
"DbCapacity": 5000000,
|
||||||
"CacheCapacity": 5000,
|
"CacheCapacity": 5000,
|
||||||
"Radius": 0,
|
"Radius": 0,
|
||||||
"Branches": 128,
|
"Branches": 128,
|
||||||
"Hash": "SHA3",
|
"Hash": "SHA3",
|
||||||
"CallInterval": 3000000000,
|
"CallInterval": 3000000000,
|
||||||
"KadDbPath": "` + filepath.Join("TMPDIR", "0d2f62485607cf38d9d795d93682a517661e513e", "bzz-peers.json") + `",
|
"KadDbPath": "` + filepath.Join("TMPDIR", "bzz-peers.json") + `",
|
||||||
"MaxProx": 8,
|
"MaxProx": 8,
|
||||||
"ProxBinSize": 2,
|
"ProxBinSize": 2,
|
||||||
"BucketSize": 4,
|
"BucketSize": 4,
|
||||||
@ -59,7 +59,7 @@ var (
|
|||||||
"Contract": "0x0000000000000000000000000000000000000000",
|
"Contract": "0x0000000000000000000000000000000000000000",
|
||||||
"Beneficiary": "0x0d2f62485607cf38d9d795d93682a517661e513e"
|
"Beneficiary": "0x0d2f62485607cf38d9d795d93682a517661e513e"
|
||||||
},
|
},
|
||||||
"RequestDbPath": "` + filepath.Join("TMPDIR", "0d2f62485607cf38d9d795d93682a517661e513e", "requests") + `",
|
"RequestDbPath": "` + filepath.Join("TMPDIR", "requests") + `",
|
||||||
"RequestDbBatchSize": 512,
|
"RequestDbBatchSize": 512,
|
||||||
"KeyBufferSize": 1024,
|
"KeyBufferSize": 1024,
|
||||||
"SyncBatchSize": 128,
|
"SyncBatchSize": 128,
|
||||||
@ -79,7 +79,7 @@ var (
|
|||||||
true,
|
true,
|
||||||
false
|
false
|
||||||
],
|
],
|
||||||
"Path": "` + filepath.Join("TMPDIR", "0d2f62485607cf38d9d795d93682a517661e513e") + `",
|
"Path": "TMPDIR",
|
||||||
"Port": "8500",
|
"Port": "8500",
|
||||||
"PublicKey": "0x045f5cfd26692e48d0017d380349bcf50982488bc11b5145f3ddf88b24924299048450542d43527fbe29a5cb32f38d62755393ac002e6bfdd71b8d7ba725ecd7a3",
|
"PublicKey": "0x045f5cfd26692e48d0017d380349bcf50982488bc11b5145f3ddf88b24924299048450542d43527fbe29a5cb32f38d62755393ac002e6bfdd71b8d7ba725ecd7a3",
|
||||||
"BzzKey": "0xe861964402c0b78e2d44098329b8545726f215afa737d803714a4338552fcb81",
|
"BzzKey": "0xe861964402c0b78e2d44098329b8545726f215afa737d803714a4338552fcb81",
|
||||||
@ -99,16 +99,12 @@ func TestConfigWriteRead(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("expected no error, got %v", err)
|
t.Fatalf("expected no error, got %v", err)
|
||||||
}
|
}
|
||||||
account := crypto.PubkeyToAddress(prvkey.PublicKey)
|
data, err := ioutil.ReadFile(filepath.Join(orig.Path, "config.json"))
|
||||||
dirpath := filepath.Join(tmp, common.Bytes2Hex(account.Bytes()))
|
|
||||||
confpath := filepath.Join(dirpath, "config.json")
|
|
||||||
data, err := ioutil.ReadFile(confpath)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("default config file cannot be read: %v", err)
|
t.Fatalf("default config file cannot be read: %v", err)
|
||||||
}
|
}
|
||||||
exp := strings.Replace(defaultConfig, "TMPDIR", tmp, -1)
|
exp := strings.Replace(defaultConfig, "TMPDIR", orig.Path, -1)
|
||||||
exp = strings.Replace(exp, "\\", "\\\\", -1)
|
exp = strings.Replace(exp, "\\", "\\\\", -1)
|
||||||
|
|
||||||
if string(data) != exp {
|
if string(data) != exp {
|
||||||
t.Fatalf("default config mismatch:\nexpected: %v\ngot: %v", exp, string(data))
|
t.Fatalf("default config mismatch:\nexpected: %v\ngot: %v", exp, string(data))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user