Skip to content

Commit

Permalink
export status strings
Browse files Browse the repository at this point in the history
  • Loading branch information
mh0lt committed Jul 10, 2024
1 parent ad9219c commit 99d65bf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,16 @@ func eventAgeString(t time.Time) string {
}

// Inspired by https://github.com/transmission/transmission/wiki/Peer-Status-Text.
func (cn *Peer) statusFlags() (ret string) {
func (cn *Peer) StatusFlags() (ret string) {
c := func(b byte) {
ret += string([]byte{b})
}
if cn.closed.IsSet() {
ret = "op-"
} else {
ret = "cl-"
}

if cn.requestState.Interested {
c('i')
}
Expand Down Expand Up @@ -354,7 +360,7 @@ func (cn *Peer) writeStatus(w io.Writer, lock bool, lockTorrent bool) {
cn.PeerMaxRequests,
len(cn.peerRequests),
localClientReqq,
cn.statusFlags(),
cn.StatusFlags(),
cn.downloadRate()/(1<<10),
)
fmt.Fprintf(w, "requested pieces:")
Expand Down

0 comments on commit 99d65bf

Please sign in to comment.