privatize fields in ledger
Brian Tiger Chow committed
Sep 10, 2014 at 20:30 UTC
7bae74287242b64b8d7ac61f299ca2d3387e4713
1 file changed
+14
-14
bitswap/ledger.go
+14
-14
@@ -16,17 +16,17 @@ type Ledger struct {
16
// Accounting tracks bytes sent and recieved.
17
Accounting debtRatio
18
19
- // FirstExchnage is the time of the first data exchange.
20
- FirstExchange time.Time
19
+ // firstExchnage is the time of the first data exchange.
20
+ firstExchange time.Time
21
22
- // LastExchange is the time of the last data exchange.
23
- LastExchange time.Time
22
+ // lastExchange is the time of the last data exchange.
23
+ lastExchange time.Time
24
25
- // Number of exchanges with this peer
26
- ExchangeCount uint64
25
+ // exchangeCount is the number of exchanges with this peer
26
+ exchangeCount uint64
27
28
- // WantList is a (bounded, small) set of keys that Partner desires.
29
- WantList KeySet
28
+ // wantList is a (bounded, small) set of keys that Partner desires.
29
+ wantList KeySet
30
31
Strategy StrategyFunc
32
}
@@ -39,23 +39,23 @@ func (l *Ledger) ShouldSend() bool {
39
}
40
41
func (l *Ledger) SentBytes(n int) {
42
- l.ExchangeCount++
43
- l.LastExchange = time.Now()
42
+ l.exchangeCount++
43
+ l.lastExchange = time.Now()
44
l.Accounting.BytesSent += uint64(n)
45
}
46
47
func (l *Ledger) ReceivedBytes(n int) {
48
- l.ExchangeCount++
49
- l.LastExchange = time.Now()
48
+ l.exchangeCount++
49
+ l.lastExchange = time.Now()
50
l.Accounting.BytesRecv += uint64(n)
51
}
52
53
// TODO: this needs to be different. We need timeouts.
54
func (l *Ledger) Wants(k u.Key) {
55
- l.WantList[k] = struct{}{}
55
+ l.wantList[k] = struct{}{}
56
}
57
58
func (l *Ledger) WantListContains(k u.Key) bool {
59
- _, ok := l.WantList[k]
59
+ _, ok := l.wantList[k]
60
return ok
61
}