// Inspired by https://github.com/transmission/transmission/wiki/Peer-Status-Text.
510584
func (cn *connection) statusFlags() (ret string) {
	c := func(b byte) {
		ret += string([]byte{b})
	}
	if cn.Interested {
		c('i')
	}
	if cn.Choked {
		c('c')
	}
	c('-')
	ret += cn.connectionFlags()
	c('-')
	if cn.PeerInterested {
		c('i')
	}
	if cn.PeerChoked {
		c('c')
	}
	return
}
656034
func (tm *TextMarshaler) Text(pb Message) string {
	var buf bytes.Buffer
	tm.Marshal(&buf, pb)
	return buf.String()
}
1197616
func (n *Network) PeerCert(p *Peer) string {
	org := n.Organization(p.Organization)
	Expect(org).NotTo(BeNil())

	return filepath.Join(
		n.PeerLocalMSPDir(p),
		"signcerts",
		fmt.Sprintf("%s.%s-cert.pem", p.Name, org.Domain),
	)
}
784824
func (peer *Peer) Receive(fromPeer *Peer, data []byte) {
	fmt.Printf("[%s] received \"%s\" from [%s]\n", peer.GetName(), string(data), fromPeer.GetName())
}
886230
func (c *Conn) SendText(text string) (err error) {
	return c._send(TextMessage, []byte(text))
}
1036660
func required(s *status.Status) (bool, string) {
	if s.Group == status.EndorserClientStatus && s.Code == status.ConnectionFailed.ToInt32() {
		return true, peerURLFromConnectionFailedStatus(s.Details)
	}
	return false, ""
}
146527
func (m *Message) DeliveryStatusRecipientDNS() ([]Header, error) {
	recipientDNS := make([]Header, 0, 1)
	if !m.HasDeliveryStatusMessage() {
		return recipientDNS, errors.New("Message does not have media content of type message/delivery-status")
	}
	var err error
	var recipientHeaders textproto.MIMEHeader
	tp := textproto.NewReader(bufio.NewReader(bytes.NewReader(m.SubMessage.Body)))
	for err != io.EOF {
		recipientHeaders, err = tp.ReadMIMEHeader()
		if err != nil && err != io.EOF {
			return nil, err
		}
		recipientDNS = append(recipientDNS, Header(recipientHeaders))
	}
	return recipientDNS, nil
}
1107313
func (p *peer) Info() *PeerInfo {
	hash, td := p.Head()

	return &PeerInfo{
		Version:    p.version,
		Difficulty: td,
		Head:       hash.Hex(),
	}
}
1124439
func (peer *Peer) send(message bytes.Buffer) (err error) {
	//Logln("Sending", message)
	Send(peer, message)
	peer.lastSent = time.Now().UnixNano()
	return nil // no error handling for now (sending is asynchronous)
}
696775
func (pw *PingWorker) StatusAsText() string {
	state := pw.State()

	result := "Ping Command with message: '" + pw.message + "'\n"
	result += "State: " + state.String() + "\n"
	switch state {
	case WorkerStateDebugRunning:
		result += "Logging message: '" + pw.message + "'\n"
	case WorkerStateDone:
		result += "Logged message: '" + pw.message + "'\n"
	}
	return result
}
636137
func (bw *BlockWorker) StatusAsText() string {
	state := bw.State()

	result := "Block Command\n"
	result += "State: " + state.String() + "\n"
	switch state {
	case WorkerStateDebugRunning:
		result += "Running (blocking)\n"
	case WorkerStateDone:
		result += "Success (unblocked)\n"
	}
	return result
}
1026081
func NewTextSubmission(sr, title, text string, replies bool, c *Captcha) *NewSubmission {
	return &NewSubmission{sr, title, text, true, replies, true, true, c}
}
20691
func (peer *respPeer) sender() {
	for {
		m := <-peer.q
		if m == nil {
			break
		}
		if peer.ep.SendMsg(m) != nil {
			m.Free()
			break
		}
	}
}
1001571
func (conn *ProtoManualConnection) NewSyncPublisherToPartition(topic string, partition int32) (messaging.ProtoPublisher, error) {
	return &protoManualSyncPublisherKafka{conn, topic, partition}, nil
}
907674
func (_m *GossipSupport) Peers() gossipdiscovery.Members {
	ret := _m.Called()

	var r0 gossipdiscovery.Members
	if rf, ok := ret.Get(0).(func() gossipdiscovery.Members); ok {
		r0 = rf()
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(gossipdiscovery.Members)
		}
	}

	return r0
}
594511
func (fci *FakeCallInfo) Text() string {
	return fmt.Sprintf("%s:%s(fakeRPC)", fci.Remote, fci.Method)
}
420013
func (whisper *Whisper) SendP2PMessage(peerID []byte, envelope *Envelope) error {
	p, err := whisper.getPeer(peerID)
	if err != nil {
		return err
	}
	return whisper.SendP2PDirect(p, envelope)
}