Skip to content

Commit

Permalink
go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Becker committed Apr 28, 2024
1 parent 68cb63b commit 40debc2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/bittorrent/swarm/piece.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ type cachedPiece struct {

// should we accept a piece data with offset and length ?
func (p *cachedPiece) accept(offset, length uint32) bool {
if offset % BlockSize != 0 {
if offset%BlockSize != 0 {
log.Errorf("Rejecting chunk where piece offset=%d % BlockSize=%d != 0", offset, BlockSize)
return false
}

if offset + length > p.length {
log.Errorf("Rejecting chunk where piece ending offset=%d > piece length=%d", offset + length, p.length)
if offset+length > p.length {
log.Errorf("Rejecting chunk where piece ending offset=%d > piece length=%d", offset+length, p.length)
return false
}
}

if p.bitfieldIndex(offset) == p.finalChunkBitfieldIndex() {
// last piece
if length != p.finalChunkLen() {
Expand Down Expand Up @@ -158,7 +158,7 @@ func (pt *pieceTracker) newPiece(piece uint32) bool {

sz := info.LengthOfPiece(piece)
bits := sz / BlockSize
if sz % BlockSize != 0 {
if sz%BlockSize != 0 {
bits++
}
log.Debugf("new piece idx=%d len=%d bits=%d", piece, sz, bits)
Expand Down

0 comments on commit 40debc2

Please sign in to comment.