good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
679c90b8
Commit
679c90b8
authored
Apr 29, 2015
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
cmd/geth, cmd/utils, eth: internalize trusted node config file
parent
de0549fa
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/geth/main.go
+0
-1
0 additions, 1 deletion
cmd/geth/main.go
cmd/utils/flags.go
+0
-6
0 additions, 6 deletions
cmd/utils/flags.go
eth/backend.go
+20
-23
20 additions, 23 deletions
eth/backend.go
with
20 additions
and
30 deletions
cmd/geth/main.go
+
0
−
1
View file @
679c90b8
...
...
@@ -233,7 +233,6 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils
.
UnlockedAccountFlag
,
utils
.
PasswordFileFlag
,
utils
.
BootNodesFlag
,
utils
.
TrustedNodesFlag
,
utils
.
DataDirFlag
,
utils
.
BlockchainVersionFlag
,
utils
.
JSpathFlag
,
...
...
This diff is collapsed.
Click to expand it.
cmd/utils/flags.go
+
0
−
6
View file @
679c90b8
...
...
@@ -207,11 +207,6 @@ var (
Usage
:
"Space-separated enode URLs for p2p discovery bootstrap"
,
Value
:
""
,
}
TrustedNodesFlag
=
cli
.
StringFlag
{
Name
:
"trustednodes"
,
Usage
:
"List of trusted nodes (either an enode list or path to a json file of enodes)"
,
Value
:
""
,
}
NodeKeyFileFlag
=
cli
.
StringFlag
{
Name
:
"nodekey"
,
Usage
:
"P2P node key file"
,
...
...
@@ -298,7 +293,6 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
Shh
:
ctx
.
GlobalBool
(
WhisperEnabledFlag
.
Name
),
Dial
:
true
,
BootNodes
:
ctx
.
GlobalString
(
BootNodesFlag
.
Name
),
TrustedNodes
:
ctx
.
GlobalString
(
TrustedNodesFlag
.
Name
),
}
}
...
...
This diff is collapsed.
Click to expand it.
eth/backend.go
+
20
−
23
View file @
679c90b8
...
...
@@ -7,6 +7,7 @@ import (
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"
"time"
...
...
@@ -39,6 +40,9 @@ var (
// ETH/DEV cpp-ethereum (poc-9.ethdev.com)
discover
.
MustParseNode
(
"enode://487611428e6c99a11a9795a6abe7b529e81315ca6aad66e2a2fc76e3adf263faba0d35466c2f8f68d561dbefa8878d4df5f1f2ddb1fbeab7f42ffb8cd328bd4a@5.1.83.226:30303"
),
}
// Path within <datadir> to search for the trusted node list
trustedNodes
=
"trusted-nodes.json"
)
type
Config
struct
{
...
...
@@ -62,10 +66,6 @@ type Config struct {
// Space-separated list of discovery node URLs
BootNodes
string
// Either a space-separated list of discovery node URLs, or a path to a json
// file containing such a list.
TrustedNodes
string
// This key is used to identify the node on the network.
// If nil, an ephemeral key is used.
NodeKey
*
ecdsa
.
PrivateKey
...
...
@@ -105,30 +105,27 @@ func (cfg *Config) parseBootNodes() []*discover.Node {
// parseTrustedNodes parses a list of discovery node URLs either given literally,
// or loaded from a .json file.
func
(
cfg
*
Config
)
parseTrustedNodes
()
[]
*
discover
.
Node
{
// Short circuit if no trusted nodes were given
if
cfg
.
TrustedNodes
==
""
{
// Short circuit if no trusted node config is present
path
:=
filepath
.
Join
(
cfg
.
DataDir
,
trustedNodes
)
if
_
,
err
:=
os
.
Stat
(
path
);
err
!=
nil
{
fmt
.
Println
(
"nodes"
,
nil
)
return
nil
}
// Try to interpret the trusted node config as a .json file
if
_
,
err
:=
os
.
Stat
(
cfg
.
TrustedNodes
);
err
==
nil
{
// Load the file from disk
blob
,
err
:=
ioutil
.
ReadFile
(
cfg
.
TrustedNodes
)
// Load the trusted nodes from the config file
blob
,
err
:=
ioutil
.
ReadFile
(
path
)
if
err
!=
nil
{
glog
.
V
(
logger
.
Error
)
.
Infof
(
"Failed to access trusted nodes: %v"
,
err
)
return
nil
}
// Interpret the json contents
list
:=
[]
string
{}
if
err
:=
json
.
Unmarshal
(
blob
,
&
list
);
err
!=
nil
{
nodelist
:=
[]
string
{}
if
err
:=
json
.
Unmarshal
(
blob
,
&
nodelist
);
err
!=
nil
{
glog
.
V
(
logger
.
Error
)
.
Infof
(
"Failed to load trusted nodes: %v"
,
err
)
return
nil
}
// Swap out the configuration for the actual nodes
cfg
.
TrustedNodes
=
strings
.
Join
(
list
,
" "
)
}
fmt
.
Println
(
"nodes"
,
nodelist
)
// Interpret the list as a discovery node array
var
nodes
[]
*
discover
.
Node
for
_
,
url
:=
range
strings
.
Split
(
cfg
.
TrustedNodes
,
" "
)
{
for
_
,
url
:=
range
nodelist
{
if
url
==
""
{
continue
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment