JKOK005 / nus-monorepo

Repo for NUS courses code commits
1 stars 0 forks source link

Node registers itself as non-local upon Finger table initialization #22

Closed JKOK005 closed 4 years ago

JKOK005 commented 4 years ago

Source: FingerTable.go line 38

` 37 >> glog.Infof("Building finger table %s:%d", myAddr, myPort)

38 >> nodeObj := &util.NodeInfo{Addr: myAddr, Port: myPort}

39 >> data, _ := json.Marshal(nodeObj)`

Since NodeInfo has a new field called isLocal, not declaring it on initialisation will cause its field to be set to False as default.

The isLocal field should be set to true since the information pertains to the local node.

stefelmanns commented 4 years ago

Changed to: glog.Infof("Building finger table %s:%d", myAddr, myPort) nodeObj := &util.NodeInfo{Addr: myAddr, Port: myPort, IsLocal: true} data, _ := json.Marshal(nodeObj)

Also adjusted lines 68-70: json.Unmarshal(nodeData, nodeInfo) successors[eInt] = *nodeInfo to json.Unmarshal(nodeData, nodeInfo) nodeInfo.IsLocal = false successors[eInt] = *nodeInfo