@@ -105,7 +105,7 @@ func (l *RTHostList) Sort() {
105
105
106
106
func (l * RTHostList ) PopFront () (h * RTHost ) {
107
107
h = l .v .At (0 ).(* RTHost )
108
- l .v .Cut (0 , 0 )
108
+ l .v .Cut (0 , 1 )
109
109
return
110
110
}
111
111
@@ -406,13 +406,11 @@ func (rt *BRoutingTable) getClosest(t string, n uint) *RTHostList {
406
406
rt .logger .Logf ("match bucket: rn %d\n " , rn )
407
407
408
408
// init for for loop
409
- cangoup := bucketno < rt .maxbucket
410
- cangodown := bucketno > 0
409
+ cangoup := ( bucketno + 1 ) <= rt .maxbucket
410
+ cangodown := ( bucketno - 1 ) >= 0
411
411
delta := 1
412
412
413
413
for (rn < n ) && (cangoup || cangodown ) {
414
- cangoup = (bucketno + delta ) < rt .maxbucket
415
- cangodown = (bucketno - delta ) > 0
416
414
//rt.logger.Logf("bucketno %d rt.maxbucket %d\n", bucketno, rt.maxbucket)
417
415
//rt.logger.Logf("bucketno - delta: %d. > 0: %v", bucketno-delta, (bucketno-delta) > 0)
418
416
//rt.logger.Logf("round delta %d cangoup %v cangodown %v\n", delta, cangoup, cangodown)
@@ -432,6 +430,8 @@ func (rt *BRoutingTable) getClosest(t string, n uint) *RTHostList {
432
430
}
433
431
434
432
delta ++
433
+ cangoup = (bucketno + delta ) < rt .maxbucket
434
+ cangodown = (bucketno - delta ) > 0
435
435
}
436
436
437
437
//rt.logger.Logf("sorting %v...\n", hl)
0 commit comments