func (d *Discovery) UpdateLocalServicesForChannel(channelID string, services []Service) {
	d.forChannel(channelID).updateLocalServices(services)
}
UpdateLocalServicesForChannel updates the cache of services for the local peer
package discovery
import (
	"context"
	"encoding/json"
	"time"
	"github.com/bluele/gcache"
	gproto "github.com/hyperledger/fabric-protos-go/gossip"
	"github.com/hyperledger/fabric/common/flogging"
	gossipapi "github.com/hyperledger/fabric/extensions/gossip/api"
	"github.com/hyperledger/fabric/gossip/api"
	"github.com/hyperledger/fabric/gossip/comm"
	gcommon "github.com/hyperledger/fabric/gossip/common"
	"github.com/hyperledger/fabric/gossip/discovery"
	extcommon "github.com/trustbloc/fabric-peer-ext/pkg/common"
	extdiscovery "github.com/trustbloc/fabric-peer-ext/pkg/common/discovery"
	"github.com/trustbloc/fabric-peer-ext/pkg/gossip/appdata"
)
var logger = flogging.MustGetLogger("sidetree_peer")
const (
	handlerDataType = "ENDPOINT_DISCOVERY"
	defaultCacheExpirationTime = 5 * time.Minute
	defaultGossipTimeout       = 5 * time.Second
	defaultGossipMaxAttempts   = 5
	defaultGossipMaxPeers      = 3
)
type appDataHandlerRegistry interface {
	Register(dataType string, handler appdata.Handler) error
}
type gossipService interface {
	PeersOfChannel(id gcommon.ChannelID) []discovery.NetworkMember
	SelfMembershipInfo() discovery.NetworkMember
	IdentityInfo() api.PeerIdentitySet
	Send(msg *gproto.GossipMessage, peers ...*comm.RemotePeer)
}
type gossipProvider interface {
	GetGossipService() gossipapi.GossipService
}
type peerConfig interface {
	PeerAddress() string
}
type discoveryConfig interface {
	DiscoveryCacheExpirationTime() time.Duration
	DiscoveryGossipMaxAttempts() int
	DiscoveryGossipTimeout() time.Duration
	DiscoveryGossipMaxPeers() int
}
type retriever interface {
	Retrieve(ctxt context.Context, request *appdata.Request, responseHandler appdata.ResponseHandler, allSet appdata.AllSet, opts ...appdata.Option) (extcommon.Values, error)
}
type servicesByPeer = map[string][]Service
type config struct {
	gossipTimeout       time.Duration
	gossipMaxAttempts   int
	gossipMaxPeers      int
	cacheExpirationTime time.Duration
}
type Discovery struct {
	config
	peerConfig
	discoveryCache gcache.Cache
	marshal        func(interface{}) ([]byte, error)
	unmarshal      func([]byte, interface{}) error
}
func New(handlerRegistry appDataHandlerRegistry, gossipProvider gossipProvider, peerCfg peerConfig, discoveryCfg discoveryConfig) *Discovery {
	cfg := newConfig(discoveryCfg)
	logger.Infof("Creating discovery service with config: %+v", cfg)
	d := &Discovery{
		config:     cfg,
		peerConfig: peerCfg,
		marshal:    json.Marshal,
		unmarshal:  json.Unmarshal,
		discoveryCache: gcache.New(0).LoaderFunc(func(chID interface{}) (interface{}, error) {
			return newChannelDiscovery(chID.(string), cfg, peerCfg, gossipProvider.GetGossipService()), nil
		}).Build(),
	}
	if err := handlerRegistry.Register(handlerDataType, d.handleDiscoveryRequest); err != nil {
		panic(err)
	}
	return d
}
func (d *Discovery) ServicesForChannel(channelID string) []Service {
	return d.forChannel(channelID).services()
}