From 60a767790db6eac6d3c5b52b964d3bdee9f6afff Mon Sep 17 00:00:00 2001 From: Fabio Barone Date: Wed, 26 Apr 2017 12:04:37 -0500 Subject: [PATCH] p2p/simulations: removed GetResourceIdFromController --- p2p/simulations/session_controller.go | 11 ----------- swarm/network/simulations/overlay.go | 9 +-------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/p2p/simulations/session_controller.go b/p2p/simulations/session_controller.go index f8e1a97d4a..1dadad5fdd 100644 --- a/p2p/simulations/session_controller.go +++ b/p2p/simulations/session_controller.go @@ -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) } diff --git a/swarm/network/simulations/overlay.go b/swarm/network/simulations/overlay.go index 3bff84fde3..fb3c211f0e 100644 --- a/swarm/network/simulations/overlay.go +++ b/swarm/network/simulations/overlay.go @@ -185,14 +185,7 @@ func nethook(conf *simulations.NetworkConfig) (simulations.NetworkControl, *simu //GET //nodes/ -- returns '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 }