Commit 7bae7428 authored by Brian Tiger Chow's avatar Brian Tiger Chow

privatize fields in ledger

parent 99db07c3
...@@ -16,17 +16,17 @@ type Ledger struct { ...@@ -16,17 +16,17 @@ type Ledger struct {
// Accounting tracks bytes sent and recieved. // Accounting tracks bytes sent and recieved.
Accounting debtRatio Accounting debtRatio
// FirstExchnage is the time of the first data exchange. // firstExchnage is the time of the first data exchange.
FirstExchange time.Time firstExchange time.Time
// LastExchange is the time of the last data exchange. // lastExchange is the time of the last data exchange.
LastExchange time.Time lastExchange time.Time
// Number of exchanges with this peer // exchangeCount is the number of exchanges with this peer
ExchangeCount uint64 exchangeCount uint64
// WantList is a (bounded, small) set of keys that Partner desires. // wantList is a (bounded, small) set of keys that Partner desires.
WantList KeySet wantList KeySet
Strategy StrategyFunc Strategy StrategyFunc
} }
...@@ -39,23 +39,23 @@ func (l *Ledger) ShouldSend() bool { ...@@ -39,23 +39,23 @@ func (l *Ledger) ShouldSend() bool {
} }
func (l *Ledger) SentBytes(n int) { func (l *Ledger) SentBytes(n int) {
l.ExchangeCount++ l.exchangeCount++
l.LastExchange = time.Now() l.lastExchange = time.Now()
l.Accounting.BytesSent += uint64(n) l.Accounting.BytesSent += uint64(n)
} }
func (l *Ledger) ReceivedBytes(n int) { func (l *Ledger) ReceivedBytes(n int) {
l.ExchangeCount++ l.exchangeCount++
l.LastExchange = time.Now() l.lastExchange = time.Now()
l.Accounting.BytesRecv += uint64(n) l.Accounting.BytesRecv += uint64(n)
} }
// TODO: this needs to be different. We need timeouts. // TODO: this needs to be different. We need timeouts.
func (l *Ledger) Wants(k u.Key) { func (l *Ledger) Wants(k u.Key) {
l.WantList[k] = struct{}{} l.wantList[k] = struct{}{}
} }
func (l *Ledger) WantListContains(k u.Key) bool { func (l *Ledger) WantListContains(k u.Key) bool {
_, ok := l.WantList[k] _, ok := l.wantList[k]
return ok return ok
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment