p2p/simulations: removed GetResourceIdFromController

This commit is contained in:
Fabio Barone 2017-04-26 12:04:37 -05:00 committed by Lewis Marshall
parent aa91242dee
commit 60a767790d
2 changed files with 1 additions and 19 deletions

View file

@ -173,17 +173,6 @@ func (self *ResourceController) SetResource(id string, c Controller) {
}
}
func (self *ResourceController) GetResourceIdForController(controller Controller) (string, error) {
self.lock.Lock()
defer self.lock.Unlock()
for id, c := range self.controllers {
if c == controller {
return id, nil
}
}
return "", fmt.Errorf("Id for Controller not found")
}
func (self *ResourceController) DeleteResource(id string) {
delete(self.controllers, id)
}

View file

@ -185,14 +185,7 @@ func nethook(conf *simulations.NetworkConfig) (simulations.NetworkControl, *simu
//GET /<networkId>/nodes/<nodeId> -- returns <nodeId>'s kademlia table
Retrieve: &simulations.ResourceHandler{
Handle: func(msg interface{}, parent *simulations.ResourceController) (interface{}, error) {
nodeId, err := nodes.GetResourceIdForController(parent)
if err != nil {
return nil, fmt.Errorf("Node could not be found")
}
if len(nodeId) != 128 {
return nil, fmt.Errorf("Node length must be 128")
}
pp := net.GetNode(adapters.NewNodeIdFromHex(nodeId)).Adapter().(*SimNode).hive
pp := net.GetNode(id).Adapter().(*SimNode).hive
if pp != nil {
return pp.String(), nil
}