func (c *Peer) SidetreeListenPort() int {
	return c.sidetreePort
}
SidetreeListenPort returns the port on which the REST services are listening
package config
import (
	"errors"
	"fmt"
	"path/filepath"
	"strings"
	"time"
	viper "github.com/spf13/viper2015"
)
const (
	sidetreeHostKey        = "sidetree.host"
	sidetreePortKey        = "sidetree.port"
	sidetreeTLSCertificate = "sidetree.tls.cert.file"
	sidetreeTLSKey         = "sidetree.tls.key.file"
	sidetreeAPITokens      = "sidetree.api.tokens"
	confPeerFileSystemPath = "peer.fileSystemPath"
	sidetreeOperationsDir  = "sidetree_ops"
	discoveryCacheExpirationTime = "sidetree.discovery.cacheExpirationTime"
	discoveryGossipTimeout       = "sidetree.discovery.gossip.timeout"
	discoveryGossipMaxPeers      = "sidetree.discovery.gossip.maxPeers"
	discoveryGossipMaxAttempts   = "sidetree.discovery.gossip.maxAttempts"
)
type Peer struct {
	sidetreeHost                 string
	sidetreePort                 int
	sidetreeTLSCertificate       string
	sidetreeTLSKey               string
	levelDBOpQueueBasePath       string
	sidetreeAPITokens            map[string]string
	discoveryGossipTimeout       time.Duration
	discoveryGossipMaxAttempts   int
	discoveryGossipMaxPeers      int
	discoveryCacheExpirationTime time.Duration
}
func NewPeer() *Peer {
	tokens := make(map[string]string)
	if viper.GetString(sidetreeAPITokens) != "" {
		for _, field := range strings.Split(viper.GetString(sidetreeAPITokens), ":") {
			split := strings.Split(field, "=")
			switch len(split) {
			case 2:
				tokens[split[0]] = split[1]
			default:
				logger.Warnf("invalid token '%s'", field)
			}
		}
	}
	return &Peer{
		sidetreeHost:                 viper.GetString(sidetreeHostKey),
		sidetreePort:                 viper.GetInt(sidetreePortKey),
		sidetreeTLSCertificate:       viper.GetString(sidetreeTLSCertificate),
		sidetreeTLSKey:               viper.GetString(sidetreeTLSKey),
		levelDBOpQueueBasePath:       filepath.Join(filepath.Clean(viper.GetString(confPeerFileSystemPath)), sidetreeOperationsDir),
		sidetreeAPITokens:            tokens,
		discoveryGossipTimeout:       viper.GetDuration(discoveryGossipTimeout),
		discoveryGossipMaxPeers:      viper.GetInt(discoveryGossipMaxPeers),
		discoveryGossipMaxAttempts:   viper.GetInt(discoveryGossipMaxAttempts),
		discoveryCacheExpirationTime: viper.GetDuration(discoveryCacheExpirationTime),
	}
}
func (c *Peer) SidetreeListenURL() (string, error) {
	host := c.sidetreeHost
	if host == "" {
		host = "0.0.0.0"
	}
	if c.sidetreePort == 0 {
		return "", errors.New("port is not set for REST service")
	}
	return fmt.Sprintf("%s:%d", host, c.sidetreePort), nil
}