-
Notifications
You must be signed in to change notification settings - Fork 189
Add core.remoteContiguousLength & remote-contiguous-length event
#743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 23 commits
31bfaaa
103f795
226a65d
b207e30
a78b6a3
b90d373
ea728de
9260453
e3a2aaa
a3ca942
064115c
24e9417
1eb4e82
31f94cb
4987ecb
7eb2809
88d1cc4
b4c21da
8fa9ef5
63f5bb3
e8ef422
39af9e5
52a3e89
2b9479e
a9d6d46
fb95516
925dadf
6fb0a71
ebed99f
8377b07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -513,18 +513,18 @@ class Peer { | |
| else this._clearLocalRange(start, length) | ||
|
|
||
| const i = Math.floor(start / DEFAULT_SEGMENT_SIZE) | ||
| const contig = this.core.header.hints.contiguousLength === this.core.state.length | ||
| const fullyContig = this.core.header.hints.contiguousLength === this.core.state.length | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (detail) unneeded renaming of the variable?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The renaming was because initially I thought it meant that the local core was contiguous even if partially so. So renamed only to clarify that it is fully contiguous in the sense that it matches the latest length. But yeah, no functionality change. |
||
|
|
||
| if ( | ||
| start + LAST_BLOCKS < this.core.state.length && | ||
| !this.remoteSegmentsWanted.has(i) && | ||
| !drop && | ||
| !contig | ||
| !fullyContig | ||
| ) | ||
| return | ||
|
|
||
| let force = false | ||
| if (contig && !drop) { | ||
| if (fullyContig && !drop) { | ||
| start = 0 | ||
| length = this.core.state.length | ||
|
|
||
|
|
@@ -1149,15 +1149,26 @@ class Peer { | |
| this._clearLocalRange(fixedStart, length) | ||
| } | ||
|
|
||
| onrange({ drop, start, length }) { | ||
| async onrange({ drop, start, length }) { | ||
| const has = drop === false | ||
|
|
||
| if (drop === true && start < this._remoteContiguousLength) { | ||
| this._remoteContiguousLength = start | ||
| } | ||
|
|
||
| if (start === 0 && drop === false) { | ||
| if (length > this._remoteContiguousLength) this._remoteContiguousLength = length | ||
| if (length > this._remoteContiguousLength) { | ||
| this._remoteContiguousLength = length | ||
| if (this.remoteFork >= this.core.state.fork) { | ||
|
||
| try { | ||
| await this.core.updateRemoteContiguousLength(length) | ||
lejeunerenard marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } catch (err) { | ||
| safetyCatch(err) | ||
| this.paused = true | ||
| return | ||
| } | ||
| } | ||
| } | ||
| } else if (length === 1) { | ||
| const bitfield = this.core.skipBitfield === null ? this.core.bitfield : this.core.skipBitfield | ||
| this.remoteBitfield.set(start, has) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.