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
b34fe0b3
Commit
b34fe0b3
authored
Mar 04, 2020
by
Dirk McCormick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs: document session idle tick behaviour
parent
fafdaaec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
+9
-0
internal/session/session.go
internal/session/session.go
+9
-0
No files found.
internal/session/session.go
View file @
b34fe0b3
...
@@ -440,6 +440,13 @@ func (s *Session) wantBlocks(ctx context.Context, newks []cid.Cid) {
...
@@ -440,6 +440,13 @@ func (s *Session) wantBlocks(ctx context.Context, newks []cid.Cid) {
}
}
}
}
// The session will broadcast if it has outstanding wants and doesn't receive
// any blocks for some time.
// The length of time is calculated
// - initially
// as a fixed delay
// - once some blocks are received
// from a base delay and average latency, with a backoff
func
(
s
*
Session
)
resetIdleTick
()
{
func
(
s
*
Session
)
resetIdleTick
()
{
var
tickDelay
time
.
Duration
var
tickDelay
time
.
Duration
if
!
s
.
latencyTrkr
.
hasLatency
()
{
if
!
s
.
latencyTrkr
.
hasLatency
()
{
...
@@ -453,6 +460,8 @@ func (s *Session) resetIdleTick() {
...
@@ -453,6 +460,8 @@ func (s *Session) resetIdleTick() {
s
.
idleTick
.
Reset
(
tickDelay
)
s
.
idleTick
.
Reset
(
tickDelay
)
}
}
// latencyTracker keeps track of the average latency between sending a want
// and receiving the corresponding block
type
latencyTracker
struct
{
type
latencyTracker
struct
{
totalLatency
time
.
Duration
totalLatency
time
.
Duration
count
int
count
int
...
...
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