func (hl *chaincodeHandlerList) foreach(e *pb.Event, action func(h *handler)) { hl.Lock() defer hl.Unlock() //if there's no chaincode event in the event... nothing to do (why was this event sent ?) if e.GetChaincodeEvent() == nil || e.GetChaincodeEvent().ChaincodeID == "" { return } //get the event map for the chaincode if emap := hl.handlers[e.GetChaincodeEvent().ChaincodeID]; emap != nil { //get the handler map for the event if handlerMap := emap[e.GetChaincodeEvent().EventName]; handlerMap != nil { for h := range handlerMap { action(h) } } //send to handlers who want all events from the chaincode, but only if //EventName is not already "" (chaincode should NOT send nameless events though) if e.GetChaincodeEvent().EventName != "" { if handlerMap := emap[""]; handlerMap != nil { for h := range handlerMap { action(h) } } } } }