diff options
author | Janos Guljas <janos@resenje.org> | 2018-09-25 22:57:31 +0800 |
---|---|---|
committer | Janos Guljas <janos@resenje.org> | 2018-09-25 22:57:31 +0800 |
commit | 24349144b6c0642755569268bab56b9033743212 (patch) | |
tree | 9d9d2b6659fd8a56512dfc807aafe4b733165ae1 /swarm/network/simulation/bucket.go | |
parent | 7d56602391e155e2ce9ba7c261300a1804ab9972 (diff) | |
parent | d3441ebb563439bac0837d70591f92e2c6080303 (diff) | |
download | go-tangerine-24349144b6c0642755569268bab56b9033743212.tar.gz go-tangerine-24349144b6c0642755569268bab56b9033743212.tar.zst go-tangerine-24349144b6c0642755569268bab56b9033743212.zip |
Merge branch 'master' into max-stream-peer-servers
Diffstat (limited to 'swarm/network/simulation/bucket.go')
-rw-r--r-- | swarm/network/simulation/bucket.go | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/swarm/network/simulation/bucket.go b/swarm/network/simulation/bucket.go index ddbedb521..bd15ea2ab 100644 --- a/swarm/network/simulation/bucket.go +++ b/swarm/network/simulation/bucket.go @@ -16,15 +16,13 @@ package simulation -import ( - "github.com/ethereum/go-ethereum/p2p/discover" -) +import "github.com/ethereum/go-ethereum/p2p/enode" // BucketKey is the type that should be used for keys in simulation buckets. type BucketKey string // NodeItem returns an item set in ServiceFunc function for a particualar node. -func (s *Simulation) NodeItem(id discover.NodeID, key interface{}) (value interface{}, ok bool) { +func (s *Simulation) NodeItem(id enode.ID, key interface{}) (value interface{}, ok bool) { s.mu.Lock() defer s.mu.Unlock() @@ -36,7 +34,7 @@ func (s *Simulation) NodeItem(id discover.NodeID, key interface{}) (value interf // SetNodeItem sets a new item associated with the node with provided NodeID. // Buckets should be used to avoid managing separate simulation global state. -func (s *Simulation) SetNodeItem(id discover.NodeID, key interface{}, value interface{}) { +func (s *Simulation) SetNodeItem(id enode.ID, key interface{}, value interface{}) { s.mu.Lock() defer s.mu.Unlock() @@ -45,12 +43,12 @@ func (s *Simulation) SetNodeItem(id discover.NodeID, key interface{}, value inte // NodesItems returns a map of items from all nodes that are all set under the // same BucketKey. -func (s *Simulation) NodesItems(key interface{}) (values map[discover.NodeID]interface{}) { +func (s *Simulation) NodesItems(key interface{}) (values map[enode.ID]interface{}) { s.mu.RLock() defer s.mu.RUnlock() ids := s.NodeIDs() - values = make(map[discover.NodeID]interface{}, len(ids)) + values = make(map[enode.ID]interface{}, len(ids)) for _, id := range ids { if _, ok := s.buckets[id]; !ok { continue @@ -63,12 +61,12 @@ func (s *Simulation) NodesItems(key interface{}) (values map[discover.NodeID]int } // UpNodesItems returns a map of items with the same BucketKey from all nodes that are up. -func (s *Simulation) UpNodesItems(key interface{}) (values map[discover.NodeID]interface{}) { +func (s *Simulation) UpNodesItems(key interface{}) (values map[enode.ID]interface{}) { s.mu.RLock() defer s.mu.RUnlock() ids := s.UpNodeIDs() - values = make(map[discover.NodeID]interface{}) + values = make(map[enode.ID]interface{}) for _, id := range ids { if _, ok := s.buckets[id]; !ok { continue |