Commit 5d611842 authored by Brian Tiger Chow's avatar Brian Tiger Chow Committed by Juan Batiz-Benet

unexport functions

License: MIT
Signed-off-by: default avatarBrian Tiger Chow <brian@perfmode.com>
parent fa7cfe40
......@@ -160,17 +160,13 @@ func (e *Engine) MessageSent(p peer.Peer, m bsmsg.BitSwapMessage) error {
return nil
}
func (e *Engine) NumBytesSentTo(p peer.Peer) uint64 {
e.lock.RLock()
defer e.lock.RUnlock()
func (e *Engine) numBytesSentTo(p peer.Peer) uint64 {
// NB not threadsafe
return e.findOrCreate(p).Accounting.BytesSent
}
func (e *Engine) NumBytesReceivedFrom(p peer.Peer) uint64 {
e.lock.RLock()
defer e.lock.RUnlock()
func (e *Engine) numBytesReceivedFrom(p peer.Peer) uint64 {
// NB not threadsafe
return e.findOrCreate(p).Accounting.BytesRecv
}
......
......@@ -44,18 +44,18 @@ func TestConsistentAccounting(t *testing.T) {
}
// Ensure sender records the change
if sender.Engine.NumBytesSentTo(receiver.Peer) == 0 {
if sender.Engine.numBytesSentTo(receiver.Peer) == 0 {
t.Fatal("Sent bytes were not recorded")
}
// Ensure sender and receiver have the same values
if sender.Engine.NumBytesSentTo(receiver.Peer) != receiver.Engine.NumBytesReceivedFrom(sender.Peer) {
if sender.Engine.numBytesSentTo(receiver.Peer) != receiver.Engine.numBytesReceivedFrom(sender.Peer) {
t.Fatal("Inconsistent book-keeping. Strategies don't agree")
}
// Ensure sender didn't record receving anything. And that the receiver
// didn't record sending anything
if receiver.Engine.NumBytesSentTo(sender.Peer) != 0 || sender.Engine.NumBytesReceivedFrom(receiver.Peer) != 0 {
if receiver.Engine.numBytesSentTo(sender.Peer) != 0 || sender.Engine.numBytesReceivedFrom(receiver.Peer) != 0 {
t.Fatal("Bert didn't send bytes to Ernie")
}
}
......
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