Merge pull request 'Handle missing remoteWants without throwing' (#9) from missing-remotewant into master

Reviewed-on: https://codeberg.org/pzp/pzp-sync/pulls/9
This commit is contained in:
Powersource 2024-05-29 15:27:51 +00:00
commit dbb4bb28e6
1 changed files with 4 additions and 8 deletions

View File

@ -260,8 +260,7 @@ class SyncStream extends Pipeable {
async #sendBloomReq(id, phase, round, remoteBloom, msgIDsForMe) { async #sendBloomReq(id, phase, round, remoteBloom, msgIDsForMe) {
// prettier-ignore // prettier-ignore
this.#debug('%s Stream IN%s: got bloom round %s plus msgIDs in %s: %o', this.#myId, phase-1, round-1, id, msgIDsForMe) this.#debug('%s Stream IN%s: got bloom round %s plus msgIDs in %s: %o', this.#myId, phase-1, round-1, id, msgIDsForMe)
const remoteWantRange = this.#remoteWant.get(id) const remoteWantRange = this.#remoteWant.get(id) ?? [0, 0]
if (!remoteWantRange) throw new Error(`Remote want-range not set for ${id}`)
this.#updateReceivableMsgs(id, msgIDsForMe) this.#updateReceivableMsgs(id, msgIDsForMe)
const msgIDsForThem = await this.#algo.getMsgsMissing( const msgIDsForThem = await this.#algo.getMsgsMissing(
id, id,
@ -293,8 +292,7 @@ class SyncStream extends Pipeable {
async #sendBloomRes(id, phase, round, remoteBloom, msgIDsForMe) { async #sendBloomRes(id, phase, round, remoteBloom, msgIDsForMe) {
// prettier-ignore // prettier-ignore
this.#debug('%s Stream IN%s: got bloom round %s plus msgIDs in %s: %o', this.#myId, phase-1, round, id, msgIDsForMe) this.#debug('%s Stream IN%s: got bloom round %s plus msgIDs in %s: %o', this.#myId, phase-1, round, id, msgIDsForMe)
const remoteWantRange = this.#remoteWant.get(id) const remoteWantRange = this.#remoteWant.get(id) ?? [0, 0]
if (!remoteWantRange) throw new Error(`Remote want-range not set for ${id}`)
this.#updateReceivableMsgs(id, msgIDsForMe) this.#updateReceivableMsgs(id, msgIDsForMe)
const msgIDsForThem = await this.#algo.getMsgsMissing( const msgIDsForThem = await this.#algo.getMsgsMissing(
id, id,
@ -325,8 +323,7 @@ class SyncStream extends Pipeable {
async #sendMissingMsgsReq(id, round, remoteBloom, msgIDsForMe) { async #sendMissingMsgsReq(id, round, remoteBloom, msgIDsForMe) {
// prettier-ignore // prettier-ignore
this.#debug('%s Stream IN7: got bloom round %s plus msgIDs in %s: %o', this.#myId, round, id, msgIDsForMe) this.#debug('%s Stream IN7: got bloom round %s plus msgIDs in %s: %o', this.#myId, round, id, msgIDsForMe)
const remoteWantRange = this.#remoteWant.get(id) const remoteWantRange = this.#remoteWant.get(id) ?? [0, 0]
if (!remoteWantRange) throw new Error(`Remote want-range not set for ${id}`)
this.#updateReceivableMsgs(id, msgIDsForMe) this.#updateReceivableMsgs(id, msgIDsForMe)
const msgIDsForThem = await this.#algo.getMsgsMissing( const msgIDsForThem = await this.#algo.getMsgsMissing(
id, id,
@ -364,8 +361,7 @@ class SyncStream extends Pipeable {
async #sendMissingMsgsRes(id, round, remoteBloom, msgsForMe) { async #sendMissingMsgsRes(id, round, remoteBloom, msgsForMe) {
// prettier-ignore // prettier-ignore
this.#debug('%s Stream IN8: got bloom round %s plus %s msgs in %s', this.#myId, round, msgsForMe.length, id) this.#debug('%s Stream IN8: got bloom round %s plus %s msgs in %s', this.#myId, round, msgsForMe.length, id)
const remoteWantRange = this.#remoteWant.get(id) const remoteWantRange = this.#remoteWant.get(id) ?? [0, 0]
if (!remoteWantRange) throw new Error(`Remote want-range not set for ${id}`)
const msgIDsForThem = await this.#algo.getMsgsMissing( const msgIDsForThem = await this.#algo.getMsgsMissing(
id, id,
round, round,