func NewService(sp view2.ServiceProvider, discovery Discovery, kvs KVS) (*service, error) {
	er := &service{
		sp:           sp,
		discovery:    discovery,
		kvs:          kvs,
		pkiResolvers: []driver.PKIResolver{},
	}
	return er, nil
}
NewService returns a new instance of the view-sdk endpoint service
package endpoint
import (
	"bytes"
	"sync"
	"github.com/pkg/errors"
	view2 "github.com/hyperledger-labs/fabric-smart-client/platform/view"
	"github.com/hyperledger-labs/fabric-smart-client/platform/view/driver"
	"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging"
	"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/kvs"
	"github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
)
var logger = flogging.MustGetLogger("view-sdk.endpoint")
type resolver struct {
	Name           string
	Domain         string
	Addresses      map[string]string
	Aliases        []string
	Id             []byte
	IdentityGetter func() (view.Identity, []byte, error)
}
func (r *resolver) GetIdentity() (view.Identity, error) {
	if r.IdentityGetter != nil {
		id, _, err := r.IdentityGetter()
		return id, err
	}
	return r.Id, nil
}
type NetworkMember struct {
	Endpoint         string
	Metadata         []byte
	PKIid            []byte
	InternalEndpoint string
}
type Discovery interface {
	Peers() []NetworkMember
}
type KVS interface {
	Exists(id string) bool
	Put(id string, state interface{}) error
	Get(id string, state interface{}) error
}
type endpointEntry struct {
	Endpoints map[driver.PortName]string
	Ephemeral view.Identity
	Identity  view.Identity
}
type service struct {
	sp             view2.ServiceProvider
	resolvers      []*resolver
	resolversMutex sync.RWMutex
	discovery      Discovery
	kvs            KVS
	pkiResolvers   []driver.PKIResolver
}