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
9e8127ac
Commit
9e8127ac
authored
May 30, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
woops
parent
17c825f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletion
+23
-1
config.go
ethutil/config.go
+23
-1
No files found.
ethutil/config.go
View file @
9e8127ac
package
ethutil
package
ethutil
import
(
import
(
"flag"
"fmt"
"fmt"
"github.com/rakyll/globalconf"
"log"
"log"
"os"
"os"
"os/user"
"os/user"
...
@@ -20,6 +22,8 @@ type config struct {
...
@@ -20,6 +22,8 @@ type config struct {
ClientString
string
ClientString
string
Pubkey
[]
byte
Pubkey
[]
byte
Identifier
string
Identifier
string
conf
*
globalconf
.
GlobalConf
}
}
const
defaultConf
=
`
const
defaultConf
=
`
...
@@ -67,11 +71,12 @@ func ApplicationFolder(base string) string {
...
@@ -67,11 +71,12 @@ func ApplicationFolder(base string) string {
// Read config
// Read config
//
//
// Initialize the global Config variable with default settings
// Initialize the global Config variable with default settings
func
ReadConfig
(
base
string
,
logTypes
LoggerType
,
id
string
)
*
config
{
func
ReadConfig
(
base
string
,
logTypes
LoggerType
,
g
*
globalconf
.
GlobalConf
,
id
string
)
*
config
{
if
Config
==
nil
{
if
Config
==
nil
{
path
:=
ApplicationFolder
(
base
)
path
:=
ApplicationFolder
(
base
)
Config
=
&
config
{
ExecPath
:
path
,
Debug
:
true
,
Ver
:
"0.5.0 RC11"
}
Config
=
&
config
{
ExecPath
:
path
,
Debug
:
true
,
Ver
:
"0.5.0 RC11"
}
Config
.
conf
=
g
Config
.
Identifier
=
id
Config
.
Identifier
=
id
Config
.
Log
=
NewLogger
(
logTypes
,
LogLevelDebug
)
Config
.
Log
=
NewLogger
(
logTypes
,
LogLevelDebug
)
Config
.
SetClientString
(
"/Ethereum(G)"
)
Config
.
SetClientString
(
"/Ethereum(G)"
)
...
@@ -90,6 +95,16 @@ func (c *config) SetClientString(str string) {
...
@@ -90,6 +95,16 @@ func (c *config) SetClientString(str string) {
Config
.
ClientString
=
fmt
.
Sprintf
(
"%s nv%s/%s"
,
str
,
c
.
Ver
,
id
)
Config
.
ClientString
=
fmt
.
Sprintf
(
"%s nv%s/%s"
,
str
,
c
.
Ver
,
id
)
}
}
func
(
c
*
config
)
SetIdentifier
(
id
string
)
{
c
.
Identifier
=
id
c
.
Set
(
"id"
,
id
)
}
func
(
c
*
config
)
Set
(
key
,
value
string
)
{
f
:=
&
flag
.
Flag
{
Name
:
key
,
Value
:
&
confValue
{
value
}}
c
.
conf
.
Set
(
""
,
f
)
}
type
LoggerType
byte
type
LoggerType
byte
const
(
const
(
...
@@ -190,3 +205,10 @@ func (log *Logger) Fatal(v ...interface{}) {
...
@@ -190,3 +205,10 @@ func (log *Logger) Fatal(v ...interface{}) {
os
.
Exit
(
1
)
os
.
Exit
(
1
)
}
}
type
confValue
struct
{
value
string
}
func
(
self
confValue
)
String
()
string
{
return
self
.
value
}
func
(
self
confValue
)
Set
(
s
string
)
error
{
self
.
value
=
s
;
return
nil
}
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