Commit b34fe0b3 authored by Dirk McCormick's avatar Dirk McCormick

docs: document session idle tick behaviour

parent fafdaaec
...@@ -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
......
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