mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 22:56:43 +00:00
p2p/simulations: removed GetResourceIdFromController
This commit is contained in:
parent
aa91242dee
commit
60a767790d
2 changed files with 1 additions and 19 deletions
|
|
@ -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) {
|
func (self *ResourceController) DeleteResource(id string) {
|
||||||
delete(self.controllers, id)
|
delete(self.controllers, id)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -185,14 +185,7 @@ func nethook(conf *simulations.NetworkConfig) (simulations.NetworkControl, *simu
|
||||||
//GET /<networkId>/nodes/<nodeId> -- returns <nodeId>'s kademlia table
|
//GET /<networkId>/nodes/<nodeId> -- returns <nodeId>'s kademlia table
|
||||||
Retrieve: &simulations.ResourceHandler{
|
Retrieve: &simulations.ResourceHandler{
|
||||||
Handle: func(msg interface{}, parent *simulations.ResourceController) (interface{}, error) {
|
Handle: func(msg interface{}, parent *simulations.ResourceController) (interface{}, error) {
|
||||||
nodeId, err := nodes.GetResourceIdForController(parent)
|
pp := net.GetNode(id).Adapter().(*SimNode).hive
|
||||||
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
|
|
||||||
if pp != nil {
|
if pp != nil {
|
||||||
return pp.String(), nil
|
return pp.String(), nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue