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
95de8551
Commit
95de8551
authored
Aug 22, 2019
by
Dirk McCormick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: move timing outside lock
parent
a2d6e30b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
session/sessionwants.go
session/sessionwants.go
+3
-1
No files found.
session/sessionwants.go
View file @
95de8551
...
...
@@ -19,6 +19,8 @@ type sessionWants struct {
// measures latency. It returns the CIDs of blocks that were actually wanted
// (as opposed to duplicates) and the total latency for all incoming blocks.
func
(
sw
*
sessionWants
)
BlocksReceived
(
cids
[]
cid
.
Cid
)
([]
cid
.
Cid
,
time
.
Duration
)
{
now
:=
time
.
Now
()
sw
.
Lock
()
defer
sw
.
Unlock
()
...
...
@@ -31,7 +33,7 @@ func (sw *sessionWants) BlocksReceived(cids []cid.Cid) ([]cid.Cid, time.Duration
// If the block CID was in the live wants queue, remove it
tval
,
ok
:=
sw
.
liveWants
[
c
]
if
ok
{
totalLatency
+=
time
.
Since
(
tval
)
totalLatency
+=
now
.
Sub
(
tval
)
delete
(
sw
.
liveWants
,
c
)
}
else
{
// Otherwise remove it from the toFetch queue, if it was there
...
...
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