reorder config, 3.3, genp2p

This commit is contained in:
Kusakabe Si
2021-12-09 22:39:37 +00:00
parent 7ef762b6b0
commit db8cf4710a
43 changed files with 854 additions and 968 deletions

View File

@ -230,10 +230,11 @@ func edge_get_superparams(w http.ResponseWriter, r *http.Request) {
}
// Do something
SuperParams := mtypes.API_SuperParams{
SendPingInterval: httpobj.http_sconfig.SendPingInterval,
HttpPostInterval: httpobj.http_sconfig.HttpPostInterval,
PeerAliveTimeout: httpobj.http_sconfig.PeerAliveTimeout,
AdditionalCost: httpobj.http_PeerID2Info[NodeID].AdditionalCost,
SendPingInterval: httpobj.http_sconfig.SendPingInterval,
HttpPostInterval: httpobj.http_sconfig.HttpPostInterval,
PeerAliveTimeout: httpobj.http_sconfig.PeerAliveTimeout,
AdditionalCost: httpobj.http_PeerID2Info[NodeID].AdditionalCost,
DampingResistance: httpobj.http_sconfig.DampingResistance,
}
SuperParamStr, _ := json.Marshal(SuperParams)
httpobj.http_PeerState[PubKey].SuperParamStateClient.Store(State)
@ -734,10 +735,11 @@ func manage_peerupdate(w http.ResponseWriter, r *http.Request) {
httpobj.http_PeerID2Info[toUpdate] = new_superpeerinfo
SuperParams := mtypes.API_SuperParams{
SendPingInterval: httpobj.http_sconfig.SendPingInterval,
HttpPostInterval: httpobj.http_sconfig.HttpPostInterval,
PeerAliveTimeout: httpobj.http_sconfig.PeerAliveTimeout,
AdditionalCost: new_superpeerinfo.AdditionalCost,
SendPingInterval: httpobj.http_sconfig.SendPingInterval,
HttpPostInterval: httpobj.http_sconfig.HttpPostInterval,
PeerAliveTimeout: httpobj.http_sconfig.PeerAliveTimeout,
DampingResistance: httpobj.http_sconfig.DampingResistance,
AdditionalCost: new_superpeerinfo.AdditionalCost,
}
SuperParamStr, _ := json.Marshal(SuperParams)
@ -797,6 +799,17 @@ func manage_superupdate(w http.ResponseWriter, r *http.Request) {
sconfig_temp.PeerAliveTimeout = PeerAliveTimeout
}
DampingResistance, err := extractParamsFloat(r.Form, "DampingResistance", 64, nil)
if err == nil {
if DampingResistance < 0 || DampingResistance >= 0 {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(fmt.Sprintf("Paramater DampingResistance %v: Must in range [0,1)\n", DampingResistance)))
return
}
Updated_params["DampingResistance"] = fmt.Sprintf("%v", DampingResistance)
sconfig_temp.DampingResistance = DampingResistance
}
SendPingInterval, err := extractParamsFloat(r.Form, "SendPingInterval", 64, nil)
if err == nil {
if SendPingInterval <= 0 || SendPingInterval >= sconfig_temp.PeerAliveTimeout {
@ -827,12 +840,14 @@ func manage_superupdate(w http.ResponseWriter, r *http.Request) {
httpobj.http_sconfig.PeerAliveTimeout = sconfig_temp.PeerAliveTimeout
httpobj.http_sconfig.SendPingInterval = sconfig_temp.SendPingInterval
httpobj.http_sconfig.HttpPostInterval = sconfig_temp.HttpPostInterval
httpobj.http_sconfig.DampingResistance = sconfig_temp.HttpPostInterval
SuperParams := mtypes.API_SuperParams{
SendPingInterval: httpobj.http_sconfig.SendPingInterval,
HttpPostInterval: httpobj.http_sconfig.HttpPostInterval,
PeerAliveTimeout: httpobj.http_sconfig.PeerAliveTimeout,
AdditionalCost: 10,
SendPingInterval: httpobj.http_sconfig.SendPingInterval,
HttpPostInterval: httpobj.http_sconfig.HttpPostInterval,
PeerAliveTimeout: httpobj.http_sconfig.PeerAliveTimeout,
DampingResistance: httpobj.http_sconfig.PeerAliveTimeout,
AdditionalCost: 10,
}
httpobj.Lock()
defer httpobj.Unlock()