Skip to content

Commit

Permalink
metadium: changed Name to NodeName to avoid conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
sadoci committed Oct 31, 2021
1 parent 7114f4c commit 117f254
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions metadium/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ func getMinerStatus() *metaapi.MetadiumMinerStatus {
defer admin.lock.Unlock()

return &metaapi.MetadiumMinerStatus{
Name: admin.self.Name,
NodeName: admin.self.Name,
Enode: admin.self.Enode,
Id: admin.self.Id,
Addr: fmt.Sprintf("%s:%d", admin.self.Ip, admin.self.Port),
Expand Down Expand Up @@ -1233,12 +1233,12 @@ func getMiners(id string, timeout int) []*metaapi.MetadiumMinerStatus {

getDownStatus := func(node *metaNode) *metaapi.MetadiumMinerStatus {
return &metaapi.MetadiumMinerStatus{
Name: node.Name,
Enode: node.Enode,
Id: node.Id,
Addr: fmt.Sprintf("%s:%d", node.Ip, node.Port),
Status: "down",
RttMs: big0,
NodeName: node.Name,
Enode: node.Enode,
Id: node.Id,
Addr: fmt.Sprintf("%s:%d", node.Ip, node.Port),
Status: "down",
RttMs: big0,
}
}

Expand Down Expand Up @@ -1312,11 +1312,11 @@ func getMiners(id string, timeout int) []*metaapi.MetadiumMinerStatus {
if !ok {
continue
}
if n, exists := peers[s.Name]; exists {
if n, exists := peers[s.NodeName]; exists {
s.RttMs = big.NewInt((time.Now().UnixNano() - startTime) / 1000000)
miners = append(miners, s)
if n != nil {
peers[s.Name] = nil
peers[s.NodeName] = nil
count--
if count <= 0 {
done = true
Expand All @@ -1338,7 +1338,7 @@ func getMiners(id string, timeout int) []*metaapi.MetadiumMinerStatus {

if len(miners) > 1 {
sort.Slice(miners, func(i, j int) bool {
return miners[i].Name < miners[j].Name
return miners[i].NodeName < miners[j].NodeName
})
}
return miners
Expand Down
2 changes: 1 addition & 1 deletion metadium/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

type MetadiumMinerStatus struct {
Name string `json:"name"`
NodeName string `json:"name"`
Enode string `json:"enode"`
Id string `json:"id"`
Addr string `json:"addr"`
Expand Down
2 changes: 1 addition & 1 deletion metadium/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (ma *metaAdmin) getLatestBlockInfo(node *metaNode) (height *big.Int, hash c
if !ok {
continue
}
if s.Name != node.Name {
if s.NodeName != node.Name {
continue
}
height, hash, td, err = s.LatestBlockHeight, s.LatestBlockHash, s.LatestBlockTd, nil
Expand Down

0 comments on commit 117f254

Please sign in to comment.