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
e2e33435
Commit
e2e33435
authored
May 31, 2019
by
hannahhoward
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(session): minor code clean-up
parent
d9488272
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
27 deletions
+21
-27
session/session.go
session/session.go
+21
-27
No files found.
session/session.go
View file @
e2e33435
...
...
@@ -87,7 +87,6 @@ type Session struct {
latTotal
time
.
Duration
fetchcnt
int
consecutiveTicks
int
lastFetchCount
int
// identifiers
notif
notifications
.
PubSub
uuid
logging
.
Loggable
...
...
@@ -98,24 +97,23 @@ type Session struct {
// given context.
func
New
(
ctx
context
.
Context
,
id
uint64
,
wm
WantManager
,
pm
PeerManager
,
srs
RequestSplitter
)
*
Session
{
s
:=
&
Session
{
liveWants
:
make
(
map
[
cid
.
Cid
]
time
.
Time
),
newReqs
:
make
(
chan
[]
cid
.
Cid
),
cancelKeys
:
make
(
chan
[]
cid
.
Cid
),
tofetch
:
newCidQueue
(),
pastWants
:
newCidQueue
(),
interestReqs
:
make
(
chan
interestReq
),
latencyReqs
:
make
(
chan
chan
time
.
Duration
),
tickDelayReqs
:
make
(
chan
time
.
Duration
),
ctx
:
ctx
,
wm
:
wm
,
pm
:
pm
,
srs
:
srs
,
incoming
:
make
(
chan
blkRecv
),
notif
:
notifications
.
New
(),
uuid
:
loggables
.
Uuid
(
"GetBlockRequest"
),
baseTickDelay
:
time
.
Millisecond
*
500
,
lastFetchCount
:
-
1
,
id
:
id
,
liveWants
:
make
(
map
[
cid
.
Cid
]
time
.
Time
),
newReqs
:
make
(
chan
[]
cid
.
Cid
),
cancelKeys
:
make
(
chan
[]
cid
.
Cid
),
tofetch
:
newCidQueue
(),
pastWants
:
newCidQueue
(),
interestReqs
:
make
(
chan
interestReq
),
latencyReqs
:
make
(
chan
chan
time
.
Duration
),
tickDelayReqs
:
make
(
chan
time
.
Duration
),
ctx
:
ctx
,
wm
:
wm
,
pm
:
pm
,
srs
:
srs
,
incoming
:
make
(
chan
blkRecv
),
notif
:
notifications
.
New
(),
uuid
:
loggables
.
Uuid
(
"GetBlockRequest"
),
baseTickDelay
:
time
.
Millisecond
*
500
,
id
:
id
,
}
cache
,
_
:=
lru
.
New
(
2048
)
...
...
@@ -314,14 +312,6 @@ func (s *Session) handleCancel(keys []cid.Cid) {
func
(
s
*
Session
)
handleTick
(
ctx
context
.
Context
)
{
if
len
(
s
.
liveWants
)
>
0
{
if
s
.
fetchcnt
==
s
.
lastFetchCount
{
s
.
consecutiveTicks
++
}
else
{
s
.
lastFetchCount
=
s
.
fetchcnt
}
}
live
:=
make
([]
cid
.
Cid
,
0
,
len
(
s
.
liveWants
))
now
:=
time
.
Now
()
for
c
:=
range
s
.
liveWants
{
...
...
@@ -339,6 +329,10 @@ func (s *Session) handleTick(ctx context.Context) {
s
.
pm
.
FindMorePeers
(
ctx
,
live
[
0
])
}
s
.
resetTick
()
if
len
(
s
.
liveWants
)
>
0
{
s
.
consecutiveTicks
++
}
}
func
(
s
*
Session
)
handleRebroadcast
(
ctx
context
.
Context
)
{
...
...
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