You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* wip
* Apply prettier to remoteContiguousLength commits thus far
* Add event listener to `remote contiguous length` test
* Add test to showcase remote contig length only updates for fully contig
To save messages being sent by all peers, the existing behavior of
sending a `range` request in `broadcastRange()` only when fully
contiguous is being kept. This means the `.remoteContiguousLength` and
the `remote-contiguous-length` event only update / fire when the remote
peer is fully contiguous and not when partially contiguous.
* Rename `contig` var to `fullyContig`
This emphasizes that the variable is true only when it is fully
contiguous, ie having the full range of blocks. This is in contrast to
being partially contiguous.
* Add test to verify truncation updates `remoteContiguousLength` too
* Update tests to include `length` arg in `remote-contiguous-length` event
* Document `.remoteContiguousLength` in README.md
Includes note that it is only updated when the peer thinks it is fully
contiguous (aka non-sparse).
* Document `remote-contiguous-length` event
* Clarify that truncating doesnt update `.remoteContiguousLength` anywhere
* Test that appends after truncating dont fire remote contig length event
* Format remote contig length event after truncate test
* Fix remoteContiguousLength hint to update on truncating
Now allows appends after truncating to fire remote contig event.
* Add test for persisting remoteContiguousLength between reloads
* Parse remoteContiguousLength when parsing header from storage
Fixes the `remote contiguous length - persists` test assuming storage
support.
* Use `truncate` & `download` events instead of timeouts in test
* Ensure contiguous lengths default to 0 when parsing header
Not likely to happen in practice, but just to be safe.
* Update remoteContiguousLength only on range starting at `0`
Peers always send `range` requests starting with `0` if they are
contiguous. Partial ranges would imply they are not contiguous so
shouldn't be able to sparsely update the `remoteContiguousLength`.
Because there is no need check the `start` of the range &
`core.updateRemoteContiguousLength()` already checks if the `length` is
larger, the logic is simplified to only call
`updateRemoteContiguousLength()` when updating the
`_remoteContiguousLength` for the peer when the range isnt a drop.
* Use `done()` to await downloads in remote contig tests
* Remove `.catch(noop)` of `.updateRemoteContiguousLength()`
Could mask underlying error and its assumed that storage errors at this
point should not be caught.
* Add test to verify remote contig length when peer truncates & appends
Should test if a reorg will correctly update the remote contiguous
length to match.
* Skip updating `remoteContiguousLength` when remote is on older fork
* Try/catch & pause if updating remote contig hint throws
* Move `updateRemoteContiguousLength()` next to `updateContiguousLength()`
* Remove try catch to let error bubble up from updating remote contig
* Move remote length check into `onrange` to avoid promise allocation
`core.updateRemoteContiguousLength()` is only called from `onrange` so
moving the check doesn't allow unviable lengths through from elsewhere.
* Change `info.hints` check style when parsing header
Use ternary instead of a combination of optional chaining and null
coalescing.
* Fix formatting
* must be same fork to update contig
---------
Co-authored-by: Mathias Buus <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+11-1Lines changed: 11 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -594,7 +594,13 @@ Populated after `ready` has been emitted. Will be `0` before the event.
594
594
595
595
#### `core.contiguousLength`
596
596
597
-
How many blocks are contiguously available starting from the first block of this core?
597
+
How many blocks are contiguously available starting from the first block of this core.
598
+
599
+
Populated after `ready` has been emitted. Will be `0` before the event.
600
+
601
+
#### `core.remoteContiguousLength`
602
+
603
+
How many blocks are contiguously available starting from the first block of this core on any known remote. This is only updated when a remote thinks it is fully contiguous such that they have all known blocks.
598
604
599
605
Populated after `ready` has been emitted. Will be `0` before the event.
600
606
@@ -708,6 +714,10 @@ Emitted when a block is uploaded to a peer.
Emitted when the max known contiguous `length` from a remote, ie `core.remoteContiguousLength`, is updated. Note this is not emitted when core is truncated.
720
+
711
721
#### `Hypercore.MAX_SUGGESTED_BLOCK_SIZE`
712
722
713
723
The constant for max size (15MB) for blocks appended to Hypercore. This max ensures blocks are replicated smoothly.
0 commit comments