Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-bitswap
Commits
5d611842
Commit
5d611842
authored
Dec 16, 2014
by
Brian Tiger Chow
Committed by
Juan Batiz-Benet
Dec 17, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unexport functions
License: MIT Signed-off-by:
Brian Tiger Chow
<
brian@perfmode.com
>
parent
fa7cfe40
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
11 deletions
+7
-11
decision/engine.go
decision/engine.go
+4
-8
decision/engine_test.go
decision/engine_test.go
+3
-3
No files found.
decision/engine.go
View file @
5d611842
...
...
@@ -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
}
...
...
decision/engine_test.go
View file @
5d611842
...
...
@@ -44,18 +44,18 @@ func TestConsistentAccounting(t *testing.T) {
}
// Ensure sender records the change
if
sender
.
Engine
.
N
umBytesSentTo
(
receiver
.
Peer
)
==
0
{
if
sender
.
Engine
.
n
umBytesSentTo
(
receiver
.
Peer
)
==
0
{
t
.
Fatal
(
"Sent bytes were not recorded"
)
}
// Ensure sender and receiver have the same values
if
sender
.
Engine
.
N
umBytesSentTo
(
receiver
.
Peer
)
!=
receiver
.
Engine
.
N
umBytesReceivedFrom
(
sender
.
Peer
)
{
if
sender
.
Engine
.
n
umBytesSentTo
(
receiver
.
Peer
)
!=
receiver
.
Engine
.
n
umBytesReceivedFrom
(
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
.
N
umBytesSentTo
(
sender
.
Peer
)
!=
0
||
sender
.
Engine
.
N
umBytesReceivedFrom
(
receiver
.
Peer
)
!=
0
{
if
receiver
.
Engine
.
n
umBytesSentTo
(
sender
.
Peer
)
!=
0
||
sender
.
Engine
.
n
umBytesReceivedFrom
(
receiver
.
Peer
)
!=
0
{
t
.
Fatal
(
"Bert didn't send bytes to Ernie"
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment