Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
power-node
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Odysseus
power-node
Commits
c31bca79
Commit
c31bca79
authored
Feb 05, 2024
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update config setting
parent
dc98f18f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
18 deletions
+47
-18
rootcmd.go
cmd/rootcmd.go
+11
-5
config.go
conf/config.go
+35
-11
config.json
config.json
+1
-2
No files found.
cmd/rootcmd.go
View file @
c31bca79
...
...
@@ -17,12 +17,13 @@ import (
)
var
(
rewardAddr
string
isSetReward
bool
=
false
rewardAddr
,
dockerServer
string
isSetReward
,
isSetDockerServer
bool
)
func
init
()
{
RootCmd
.
PersistentFlags
()
.
StringVarP
(
&
rewardAddr
,
"reward"
,
"r"
,
""
,
"please enter a reward address"
)
RootCmd
.
PersistentFlags
()
.
StringVarP
(
&
dockerServer
,
"docker_server"
,
"d"
,
""
,
"please enter docker server address"
)
cobra
.
OnInitialize
(
initConfig
)
}
...
...
@@ -32,14 +33,19 @@ var RootCmd = &cobra.Command{
Short
:
"The miner command-line interface"
,
Long
:
``
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
if
rewardAddr
!=
""
{
log
.
Info
(
"Enter reward address:"
,
rewardAddr
)
if
rewardAddr
!=
""
&&
dockerServer
!=
""
{
isSetDockerServer
=
conf
.
GetConfig
()
.
SetDockerServerUrl
(
dockerServer
)
if
!
isSetDockerServer
{
log
.
Error
(
"Enter right docker server address:"
,
dockerServer
)
}
log
.
Info
(
"Enter docker server url:"
,
dockerServer
)
isSetReward
=
conf
.
GetConfig
()
.
SetRewardAddress
(
rewardAddr
)
if
!
isSetReward
{
log
.
Error
(
"Please set right reward address"
)
}
log
.
Info
(
"Enter reward address:"
,
rewardAddr
)
}
if
isSetReward
{
if
isSetReward
&&
isSetDockerServer
{
log
.
InitLog
(
log
.
LogConfig
{
Path
:
"logs"
,
Level
:
"debug"
,
Save
:
3
})
go
nm
.
StartMonitor
()
beego
.
Run
()
...
...
conf/config.go
View file @
c31bca79
...
...
@@ -2,25 +2,27 @@ package conf
import
(
"crypto/ecdsa"
"example.com/m/log"
"github.com/ethereum/go-ethereum/common"
"net/url"
)
type
Config
struct
{
NmSeed
string
`json:"nm_seed"`
SignPrv
string
SignPrivateKey
*
ecdsa
.
PrivateKey
SignPub
string
SignPublicAddress
common
.
Address
DockerServer
string
`json:"docker_server"`
HeartRespTimeSecond
int64
`json:"heart_response"`
DockerServer
string
BenefitAddress
string
HeartRespTimeMillis
int64
SignPublicAddress
common
.
Address
SignPrivateKey
*
ecdsa
.
PrivateKey
NmSeed
string
`json:"nm_seed"`
HeartRespTimeSecond
int64
`json:"heart_response"`
TaskValidatorTime
float64
`json:"task_validator_time"`
BenefitAddress
string
ContainerNum
int64
`json:"container_num"`
NodeManagerNum
int64
`json:"node_manager_num"`
ChainID
int64
`json:"chain_id"`
ApiUrl
string
`json:"api_url"`
ValidatorUrl
string
`json:"validator_url"`
ContainerNum
int64
`json:"container_num"`
NodeManagerNum
int64
`json:"node_manager_num"`
ChainID
int64
`json:"chain_id"`
ApiUrl
string
`json:"api_url"`
ValidatorUrl
string
`json:"validator_url"`
}
var
_cfg
*
Config
=
nil
...
...
@@ -41,6 +43,28 @@ func (c *Config) SetRewardAddress(addr string) bool {
return
isAddr
}
func
(
c
*
Config
)
SetDockerServerUrl
(
url
string
)
bool
{
isSuccess
:=
checkDockerServer
(
url
)
if
isSuccess
{
c
.
DockerServer
=
url
}
return
isSuccess
}
func
(
c
*
Config
)
SetNmSeed
(
seed
string
)
{
c
.
NmSeed
=
seed
}
func
checkDockerServer
(
rawURL
string
)
bool
{
parsedURL
,
err
:=
url
.
Parse
(
rawURL
)
if
err
!=
nil
{
log
.
Error
(
"Error parsing URL:"
,
err
)
return
false
}
// 提取协议、主机和端口信息
protocol
:=
parsedURL
.
Scheme
if
protocol
!=
"tcp"
{
return
false
}
return
true
}
config.json
View file @
c31bca79
{
"nm_seed"
:
"43.198.252.255:10001"
,
"docker_server"
:
"tcp://127.0.0.1:2375"
,
"api_url"
:
"http://43.198.252.255:8087/api/task/taskheat"
,
"api_url"
:
"https://console.aigic.ai/api/task/taskheat"
,
"node_manager_num"
:
1
,
"heart_response"
:
30
,
"task_validator_time"
:
1
,
...
...
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