Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
ef50e01c
Commit
ef50e01c
authored
Sep 22, 2016
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swarm/api: add bzz prefix to swarm directory
parent
cc0064b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
12 deletions
+7
-12
config.go
swarm/api/config.go
+1
-2
config_test.go
swarm/api/config_test.go
+6
-10
No files found.
swarm/api/config.go
View file @
ef50e01c
...
...
@@ -59,9 +59,8 @@ type Config struct {
// config is agnostic to where private key is coming from
// so managing accounts is outside swarm and left to wrappers
func
NewConfig
(
path
string
,
contract
common
.
Address
,
prvKey
*
ecdsa
.
PrivateKey
)
(
self
*
Config
,
err
error
)
{
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
)
if
err
!=
nil
{
return
...
...
swarm/api/config_test.go
View file @
ef50e01c
...
...
@@ -30,14 +30,14 @@ import (
var
(
hexprvkey
=
"65138b2aa745041b372153550584587da326ab440576b2a1191dd95cee30039c"
defaultConfig
=
`{
"ChunkDbPath": "`
+
filepath
.
Join
(
"TMPDIR"
,
"
0d2f62485607cf38d9d795d93682a517661e513e"
,
"
chunks"
)
+
`",
"ChunkDbPath": "`
+
filepath
.
Join
(
"TMPDIR"
,
"chunks"
)
+
`",
"DbCapacity": 5000000,
"CacheCapacity": 5000,
"Radius": 0,
"Branches": 128,
"Hash": "SHA3",
"CallInterval": 3000000000,
"KadDbPath": "`
+
filepath
.
Join
(
"TMPDIR"
,
"
0d2f62485607cf38d9d795d93682a517661e513e"
,
"
bzz-peers.json"
)
+
`",
"KadDbPath": "`
+
filepath
.
Join
(
"TMPDIR"
,
"bzz-peers.json"
)
+
`",
"MaxProx": 8,
"ProxBinSize": 2,
"BucketSize": 4,
...
...
@@ -59,7 +59,7 @@ var (
"Contract": "0x0000000000000000000000000000000000000000",
"Beneficiary": "0x0d2f62485607cf38d9d795d93682a517661e513e"
},
"RequestDbPath": "`
+
filepath
.
Join
(
"TMPDIR"
,
"
0d2f62485607cf38d9d795d93682a517661e513e"
,
"
requests"
)
+
`",
"RequestDbPath": "`
+
filepath
.
Join
(
"TMPDIR"
,
"requests"
)
+
`",
"RequestDbBatchSize": 512,
"KeyBufferSize": 1024,
"SyncBatchSize": 128,
...
...
@@ -79,7 +79,7 @@ var (
true,
false
],
"Path": "
`
+
filepath
.
Join
(
"TMPDIR"
,
"0d2f62485607cf38d9d795d93682a517661e513e"
)
+
`
",
"Path": "
TMPDIR
",
"Port": "8500",
"PublicKey": "0x045f5cfd26692e48d0017d380349bcf50982488bc11b5145f3ddf88b24924299048450542d43527fbe29a5cb32f38d62755393ac002e6bfdd71b8d7ba725ecd7a3",
"BzzKey": "0xe861964402c0b78e2d44098329b8545726f215afa737d803714a4338552fcb81",
...
...
@@ -99,16 +99,12 @@ func TestConfigWriteRead(t *testing.T) {
if
err
!=
nil
{
t
.
Fatalf
(
"expected no error, got %v"
,
err
)
}
account
:=
crypto
.
PubkeyToAddress
(
prvkey
.
PublicKey
)
dirpath
:=
filepath
.
Join
(
tmp
,
common
.
Bytes2Hex
(
account
.
Bytes
()))
confpath
:=
filepath
.
Join
(
dirpath
,
"config.json"
)
data
,
err
:=
ioutil
.
ReadFile
(
confpath
)
data
,
err
:=
ioutil
.
ReadFile
(
filepath
.
Join
(
orig
.
Path
,
"config.json"
))
if
err
!=
nil
{
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
)
if
string
(
data
)
!=
exp
{
t
.
Fatalf
(
"default config mismatch:
\n
expected: %v
\n
got: %v"
,
exp
,
string
(
data
))
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment