Commit f9e65631 authored by szh's avatar szh

add json

parent 925657cd
...@@ -101,7 +101,7 @@ func broadcast() { ...@@ -101,7 +101,7 @@ func broadcast() {
if err != nil{ if err != nil{
fmt.Println(err) fmt.Println(err)
} }
log.Println(send) //log.Println(send)
time.Sleep(time.Second) time.Sleep(time.Second)
} }
} }
\ No newline at end of file
...@@ -12,18 +12,24 @@ import ( ...@@ -12,18 +12,24 @@ import (
) )
type Pai struct { type Pai struct {
Hardware string Hardware string `json:"hardware"`
Revision string Revision string `json:"revision"`
Serial string Serial string `json:"serial"`
//PeerList *types.PeerList //PeerList *types.PeerList
LocalLastHeight int64 LocalLastHeight int64 `json:"local_last_height"`
LastHeight int64 LastHeight int64 `json:"last_height"`
IsNtpSync bool IsNtpSync bool `json:"is_ntp_sync"`
WalletStatus *types.WalletStatus WalletStatus *types.WalletStatus `json:"wallet_status"`
NetInfo *types.NodeNetInfo NetInfo *types.NodeNetInfo `json:"net_info"`
} }
var pai_serial string
func (p *Pai) GetConfig() bool { func (p *Pai) GetConfig() bool {
if pai_serial != "" {
logging.Debug("pai_serial",pai_serial)
p.Serial = pai_serial
}
if p.Serial != "" { if p.Serial != "" {
return true return true
} }
...@@ -93,15 +99,18 @@ func getPaiConfig(command string ,arg ...string) (config map[string]string,err e ...@@ -93,15 +99,18 @@ func getPaiConfig(command string ,arg ...string) (config map[string]string,err e
if err!=nil || io.EOF==err{ if err!=nil || io.EOF==err{
break break
}else{ }else{
fmt.Println("line", line) //fmt.Println("line", line)
l := strings.Split(line, ":") l := strings.Split(line, ":")
if len(l) == 2 { if len(l) == 2 {
k := strings.ToLower(strings.TrimRight(strings.Trim(strings.Replace(l[0], " ", " ", -1), " "), " ")) k := strings.ToLower(strings.TrimRight(strings.Trim(strings.Replace(l[0], " ", " ", -1), " "), " "))
v := strings.Trim(strings.Replace(l[1], "\n", "", -1), " ") v := strings.Trim(strings.Replace(l[1], "\n", "", -1), " ")
fmt.Println("KEY:",k, "VAL:", v) //fmt.Println("KEY:",k, "VAL:", v)
if _, ok := list[k]; !ok { if _, ok := list[k]; !ok {
list[k] = v list[k] = v
if k == "serial" {
pai_serial = v
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment