Skip to content

Commit

Permalink
Same modification for CacheTorrent.
Browse files Browse the repository at this point in the history
  • Loading branch information
danalex97 committed May 1, 2018
1 parent 32eb23d commit e455121
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cache_torrent/picker.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (p *CachePicker) IsBanned(index int) bool {

// once we have a piece we can save some memory by deleting the haves of
// those pieces
for _, have := range p.have {
for _, have := range p.Have {
delete(have, index)
}
}
Expand Down
14 changes: 7 additions & 7 deletions torrent/picker.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type TorrentPicker struct {
buckets map[int]map[int]bool // map from frequency to bucket
// a bucket is a set of indexes having a specific frequency

have map[string]map[int]bool // the pieces that the remote peers have
Have map[string]map[int]bool // the pieces that the remote peers have
active map[int]int // number of active requests for a piece

Bans map[int]bool // the pieces that I already have stored
Expand All @@ -63,10 +63,10 @@ func (p *TorrentPicker) GotHave(peer string, index int) {
defer p.Unlock()

// update have
if _, ok := p.have[peer]; !ok {
p.have[peer] = make(map[int]bool)
if _, ok := p.Have[peer]; !ok {
p.Have[peer] = make(map[int]bool)
}
p.have[peer][index] = true
p.Have[peer][index] = true

// update freq
if _, ok := p.freq[index]; !ok {
Expand Down Expand Up @@ -132,10 +132,10 @@ func (p *TorrentPicker) IterateBuckers(peer string, selector Selector) (int, boo
* @tiebreaks: set of pieces with active started requests
*/

haves := p.have[peer]
haves := p.Have[peer]
if haves == nil {
haves = make(map[int]bool)
p.have[peer] = haves
p.Have[peer] = haves
}
tiebreaks := p.active

Expand Down Expand Up @@ -215,7 +215,7 @@ func (p *TorrentPicker) IsBanned(index int) bool {

// once we have a piece we can save some memory by deleting the haves of
// those pieces
for _, have := range p.have {
for _, have := range p.Have {
delete(have, index)
}
}
Expand Down

0 comments on commit e455121

Please sign in to comment.