From e0f0617b0b41d876c6e0c6d862beadeee61725bb Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sat, 7 Jul 2018 11:33:48 +1000 Subject: [PATCH] Comments and readability --- config.go | 3 +-- connection.go | 6 +++++- peer_protocol/decoder.go | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/config.go b/config.go index 899a2f06..0c6141c6 100644 --- a/config.go +++ b/config.go @@ -41,8 +41,7 @@ type ClientConfig struct { // Disable uploading even when it isn't fair. DisableAggressiveUpload bool `long:"disable-aggressive-upload"` // Upload even after there's nothing in it for us. By default uploading is - // not altruistic, we'll upload slightly more than we download from each - // peer. + // not altruistic, we'll only upload to encourage the peer to reciprocate. Seed bool `long:"seed"` // Only applies to chunks uploaded to peers, to maintain responsiveness // communicating local Client state to peers. Each limiter token diff --git a/connection.go b/connection.go index ba739d92..7bad4f27 100644 --- a/connection.go +++ b/connection.go @@ -398,7 +398,11 @@ func (cn *connection) nominalMaxRequests() (ret int) { ), )) } - return int(clamp(1, int64(cn.PeerMaxRequests), max(64, cn.stats.ChunksReadUseful.Int64()-(cn.stats.ChunksRead.Int64()-cn.stats.ChunksReadUseful.Int64())))) + return int(clamp( + 1, + int64(cn.PeerMaxRequests), + max(64, + cn.stats.ChunksReadUseful.Int64()-(cn.stats.ChunksRead.Int64()-cn.stats.ChunksReadUseful.Int64())))) } func (cn *connection) totalExpectingTime() (ret time.Duration) { diff --git a/peer_protocol/decoder.go b/peer_protocol/decoder.go index 37758fd8..e4aeab08 100644 --- a/peer_protocol/decoder.go +++ b/peer_protocol/decoder.go @@ -35,7 +35,7 @@ func (d *Decoder) Decode(msg *Message) (err error) { return } msg.Keepalive = false - r := &io.LimitedReader{d.R, int64(length)} + r := &io.LimitedReader{R:d.R, N:int64(length)} // Check that all of r was utilized. defer func() { if err != nil { -- 2.48.1