Fix bug manage_superupdate

This commit is contained in:
Kusakabe Si
2021-12-10 00:22:25 +00:00
parent db8cf4710a
commit 89f1548dd4
4 changed files with 13 additions and 12 deletions

2
.vscode/launch.json vendored
View File

@ -22,7 +22,7 @@
"program": "${workspaceFolder}", "program": "${workspaceFolder}",
"buildFlags": "-tags 'novpp'", "buildFlags": "-tags 'novpp'",
"env": {"CGO_CFLAGS":"-I/usr/include/memif"}, "env": {"CGO_CFLAGS":"-I/usr/include/memif"},
"args":["-config","example_config/p2p_mode/EgNet_edge1.yaml","-mode","edge"/*,"-example"*/], "args":["-config","example_config/super_mode/EgNet_edge001.yaml","-mode","edge"/*,"-example"*/],
}, },
{ {
"name": "Launch GenCfg", "name": "Launch GenCfg",

View File

@ -19,11 +19,11 @@ LogLevel:
LogInternal: true LogInternal: true
LogNTP: true LogNTP: true
Passwords: Passwords:
ShowState: zOWP0T9O_showstate ShowState: passwd_showstate
AddPeer: zOWP0T9O_addpeer AddPeer: passwd_addpeer
DelPeer: zOWP0T9O_delpeer DelPeer: passwd_delpeer
UpdatePeer: zOWP0T9O_updatepeer UpdatePeer: passwd_updatepeer
UpdateSuper: zOWP0T9O_updatesuper UpdateSuper: passwd_updatesuper
GraphRecalculateSetting: GraphRecalculateSetting:
StaticMode: false StaticMode: false
ManualLatency: {} ManualLatency: {}

View File

@ -276,7 +276,7 @@ curl "http://127.0.0.1:3456/eg_net/eg_api/manage/peer/del?PrivKey=iquaLyD%2BYLzW
### peer/update ### peer/update
更新節點的一些參數 更新節點的一些參數
```bash ```bash
curl -X POST "http://127.0.0.1:3456/eg_net/eg_api/eg_api/manage/peer/update?Password=e05znou1_updatepeer&NodeID=1" \ curl -X POST "http://127.0.0.1:3456/eg_net/eg_api/manage/peer/update?Password=passwd_updatepeer&NodeID=1" \
-H "Content-Type: application/x-www-form-urlencoded" \ -H "Content-Type: application/x-www-form-urlencoded" \
-d "AdditionalCost=10&SkipLocalIP=false" -d "AdditionalCost=10&SkipLocalIP=false"
``` ```
@ -284,9 +284,9 @@ curl -X POST "http://127.0.0.1:3456/eg_net/eg_api/eg_api/manage/peer/update?Pass
### super/update ### super/update
更新SuperNode的一些參數 更新SuperNode的一些參數
```bash ```bash
curl -X POST "http://127.0.0.1:3456/eg_net/eg_api/eg_api/manage/super/update?Password=e05znou1_updatesuper" \ curl -X POST "http://127.0.0.1:3456/eg_net/eg_api/manage/super/update?Password=passwd_updatesuper" \
-H "Content-Type: application/x-www-form-urlencoded" \ -H "Content-Type: application/x-www-form-urlencoded" \
-d "SendPingInterval=15&HttpPostInterval=60&PeerAliveTimeout=70DampingResistance=0.9" -d "SendPingInterval=15&HttpPostInterval=60&PeerAliveTimeout=70&DampingResistance=0.9"
``` ```
### SuperNode Config Parameter ### SuperNode Config Parameter

View File

@ -787,6 +787,7 @@ func manage_superupdate(w http.ResponseWriter, r *http.Request) {
sconfig_temp.PeerAliveTimeout = httpobj.http_sconfig.PeerAliveTimeout sconfig_temp.PeerAliveTimeout = httpobj.http_sconfig.PeerAliveTimeout
sconfig_temp.SendPingInterval = httpobj.http_sconfig.SendPingInterval sconfig_temp.SendPingInterval = httpobj.http_sconfig.SendPingInterval
sconfig_temp.HttpPostInterval = httpobj.http_sconfig.HttpPostInterval sconfig_temp.HttpPostInterval = httpobj.http_sconfig.HttpPostInterval
sconfig_temp.DampingResistance = httpobj.http_sconfig.DampingResistance
PeerAliveTimeout, err := extractParamsFloat(r.Form, "PeerAliveTimeout", 64, nil) PeerAliveTimeout, err := extractParamsFloat(r.Form, "PeerAliveTimeout", 64, nil)
if err == nil { if err == nil {
@ -801,7 +802,7 @@ func manage_superupdate(w http.ResponseWriter, r *http.Request) {
DampingResistance, err := extractParamsFloat(r.Form, "DampingResistance", 64, nil) DampingResistance, err := extractParamsFloat(r.Form, "DampingResistance", 64, nil)
if err == nil { if err == nil {
if DampingResistance < 0 || DampingResistance >= 0 { if DampingResistance < 0 || DampingResistance >= 1 {
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(fmt.Sprintf("Paramater DampingResistance %v: Must in range [0,1)\n", DampingResistance))) w.Write([]byte(fmt.Sprintf("Paramater DampingResistance %v: Must in range [0,1)\n", DampingResistance)))
return return
@ -840,13 +841,13 @@ func manage_superupdate(w http.ResponseWriter, r *http.Request) {
httpobj.http_sconfig.PeerAliveTimeout = sconfig_temp.PeerAliveTimeout httpobj.http_sconfig.PeerAliveTimeout = sconfig_temp.PeerAliveTimeout
httpobj.http_sconfig.SendPingInterval = sconfig_temp.SendPingInterval httpobj.http_sconfig.SendPingInterval = sconfig_temp.SendPingInterval
httpobj.http_sconfig.HttpPostInterval = sconfig_temp.HttpPostInterval httpobj.http_sconfig.HttpPostInterval = sconfig_temp.HttpPostInterval
httpobj.http_sconfig.DampingResistance = sconfig_temp.HttpPostInterval httpobj.http_sconfig.DampingResistance = sconfig_temp.DampingResistance
SuperParams := mtypes.API_SuperParams{ SuperParams := mtypes.API_SuperParams{
SendPingInterval: httpobj.http_sconfig.SendPingInterval, SendPingInterval: httpobj.http_sconfig.SendPingInterval,
HttpPostInterval: httpobj.http_sconfig.HttpPostInterval, HttpPostInterval: httpobj.http_sconfig.HttpPostInterval,
PeerAliveTimeout: httpobj.http_sconfig.PeerAliveTimeout, PeerAliveTimeout: httpobj.http_sconfig.PeerAliveTimeout,
DampingResistance: httpobj.http_sconfig.PeerAliveTimeout, DampingResistance: httpobj.http_sconfig.DampingResistance,
AdditionalCost: 10, AdditionalCost: 10,
} }
httpobj.Lock() httpobj.Lock()