swarm/network: Simplify bucket instantiation in servicectx func

This commit is contained in:
lash 2019-03-19 16:26:36 +01:00
parent 19b0bd5b44
commit a9c44e0b85

View file

@ -85,9 +85,8 @@ func New(services map[string]ServiceFunc) (s *Simulation) {
name, serviceFunc := name, serviceFunc
s.serviceNames = append(s.serviceNames, name)
adapterServices[name] = func(ctx *adapters.ServiceContext) (node.Service, error) {
var b *sync.Map
var ok bool
if b, ok = s.buckets[ctx.Config.ID]; !ok {
b, ok := s.buckets[ctx.Config.ID]
if !ok {
b = new(sync.Map)
}
service, cleanup, err := serviceFunc(ctx, b)