-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: sync should only happen when both sides are enabled (#764)
This change: - Fixes core unreplication, closing issue [#762]. - Adds "fuzz testing" for sync, which tries a bunch of random actions and makes sure things work as expected. [#762]: #762 Co-Authored-By: Gregor MacLennan <[email protected]>
- Loading branch information
1 parent
770a8dc
commit b61e132
Showing
7 changed files
with
577 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { assert } from '../utils.js' | ||
|
||
/** | ||
* @param {import('hypercore')<'binary', any>} core Core to unreplicate. Must be ready. | ||
* @param {import('protomux')} protomux | ||
*/ | ||
export function unreplicate(core, protomux) { | ||
assert(core.discoveryKey, 'Core should have a discovery key') | ||
protomux.unpair({ | ||
protocol: 'hypercore/alpha', | ||
id: core.discoveryKey, | ||
}) | ||
for (const channel of protomux) { | ||
if (channel.protocol !== 'hypercore/alpha') continue | ||
if (!channel.id.equals(core.discoveryKey)) continue | ||
channel.close() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.