mirror of https://codeberg.org/pzp/pzp-sync.git
Improve error messages in Stream
This commit is contained in:
parent
1d3169724d
commit
e9971410eb
|
@ -170,7 +170,7 @@ class SyncStream extends Pipeable {
|
||||||
this.#remoteWant.set(id, remoteWantRange)
|
this.#remoteWant.set(id, remoteWantRange)
|
||||||
const goal = this.#goals.get(id)
|
const goal = this.#goals.get(id)
|
||||||
const haveRange = this.#localHave.get(id)
|
const haveRange = this.#localHave.get(id)
|
||||||
if (!haveRange) throw new Error('local have-range not set')
|
if (!haveRange) throw new Error(`Local have-range not set for ${id}`)
|
||||||
const localWant = this.#algo.wantRange(haveRange, remoteHaveRange, goal)
|
const localWant = this.#algo.wantRange(haveRange, remoteHaveRange, goal)
|
||||||
this.#localWant.set(id, localWant)
|
this.#localWant.set(id, localWant)
|
||||||
const localBloom0 = this.#algo.bloomFor(id, 0, localWant)
|
const localBloom0 = this.#algo.bloomFor(id, 0, localWant)
|
||||||
|
@ -200,7 +200,7 @@ class SyncStream extends Pipeable {
|
||||||
)
|
)
|
||||||
this.#updateSendableMsgs(id, msgIDsForThem)
|
this.#updateSendableMsgs(id, msgIDsForThem)
|
||||||
const localWantRange = this.#localWant.get(id)
|
const localWantRange = this.#localWant.get(id)
|
||||||
if (!localWantRange) throw new Error('local want-range not set')
|
if (!localWantRange) throw new Error(`Local want-range not set for ${id}`)
|
||||||
const localBloom = this.#algo.bloomFor(id, 0, localWantRange)
|
const localBloom = this.#algo.bloomFor(id, 0, localWantRange)
|
||||||
this.sink.write({
|
this.sink.write({
|
||||||
id,
|
id,
|
||||||
|
@ -222,7 +222,7 @@ class SyncStream extends Pipeable {
|
||||||
// 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)
|
||||||
if (!remoteWantRange) throw new Error('remote want-range not set')
|
if (!remoteWantRange) throw new Error(`Remote want-range not set for ${id}`)
|
||||||
this.#updateReceivableMsgs(id, msgIDsForMe)
|
this.#updateReceivableMsgs(id, msgIDsForMe)
|
||||||
const msgIDsForThem = this.#algo.getMsgsMissing(
|
const msgIDsForThem = this.#algo.getMsgsMissing(
|
||||||
id,
|
id,
|
||||||
|
@ -233,7 +233,7 @@ class SyncStream extends Pipeable {
|
||||||
this.#updateSendableMsgs(id, msgIDsForThem)
|
this.#updateSendableMsgs(id, msgIDsForThem)
|
||||||
const extras = this.#receivableMsgs.get(id)
|
const extras = this.#receivableMsgs.get(id)
|
||||||
const localWantRange = this.#localWant.get(id)
|
const localWantRange = this.#localWant.get(id)
|
||||||
if (!localWantRange) throw new Error('local want-range not set')
|
if (!localWantRange) throw new Error(`Local want-range not set for ${id}`)
|
||||||
const localBloom = this.#algo.bloomFor(id, round, localWantRange, extras)
|
const localBloom = this.#algo.bloomFor(id, round, localWantRange, extras)
|
||||||
this.sink.write({
|
this.sink.write({
|
||||||
id,
|
id,
|
||||||
|
@ -255,7 +255,7 @@ class SyncStream extends Pipeable {
|
||||||
// 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)
|
||||||
if (!remoteWantRange) throw new Error('remote want-range not set')
|
if (!remoteWantRange) throw new Error(`Remote want-range not set for ${id}`)
|
||||||
this.#updateReceivableMsgs(id, msgIDsForMe)
|
this.#updateReceivableMsgs(id, msgIDsForMe)
|
||||||
const msgIDsForThem = this.#algo.getMsgsMissing(
|
const msgIDsForThem = this.#algo.getMsgsMissing(
|
||||||
id,
|
id,
|
||||||
|
@ -266,7 +266,7 @@ class SyncStream extends Pipeable {
|
||||||
this.#updateSendableMsgs(id, msgIDsForThem)
|
this.#updateSendableMsgs(id, msgIDsForThem)
|
||||||
const extras = this.#receivableMsgs.get(id)
|
const extras = this.#receivableMsgs.get(id)
|
||||||
const localWantRange = this.#localWant.get(id)
|
const localWantRange = this.#localWant.get(id)
|
||||||
if (!localWantRange) throw new Error('local want-range not set')
|
if (!localWantRange) throw new Error(`Local want-range not set for ${id}`)
|
||||||
const localBloom = this.#algo.bloomFor(id, round, localWantRange, extras)
|
const localBloom = this.#algo.bloomFor(id, round, localWantRange, extras)
|
||||||
this.sink.write({
|
this.sink.write({
|
||||||
id,
|
id,
|
||||||
|
@ -287,7 +287,7 @@ class SyncStream extends Pipeable {
|
||||||
// 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)
|
||||||
if (!remoteWantRange) throw new Error('remote want-range not set')
|
if (!remoteWantRange) throw new Error(`Remote want-range not set for ${id}`)
|
||||||
this.#updateReceivableMsgs(id, msgIDsForMe)
|
this.#updateReceivableMsgs(id, msgIDsForMe)
|
||||||
const msgIDsForThem = this.#algo.getMsgsMissing(
|
const msgIDsForThem = this.#algo.getMsgsMissing(
|
||||||
id,
|
id,
|
||||||
|
@ -302,7 +302,7 @@ class SyncStream extends Pipeable {
|
||||||
const msgs = accountMsgs.concat(tangleMsgs)
|
const msgs = accountMsgs.concat(tangleMsgs)
|
||||||
const extras = this.#receivableMsgs.get(id)
|
const extras = this.#receivableMsgs.get(id)
|
||||||
const localWantRange = this.#localWant.get(id)
|
const localWantRange = this.#localWant.get(id)
|
||||||
if (!localWantRange) throw new Error('local want-range not set')
|
if (!localWantRange) throw new Error(`Local want-range not set for ${id}`)
|
||||||
const localBloom = this.#algo.bloomFor(id, round, localWantRange, extras)
|
const localBloom = this.#algo.bloomFor(id, round, localWantRange, extras)
|
||||||
this.sink.write({
|
this.sink.write({
|
||||||
id,
|
id,
|
||||||
|
@ -323,7 +323,7 @@ class SyncStream extends Pipeable {
|
||||||
// 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)
|
||||||
if (!remoteWantRange) throw new Error('remote want-range not set')
|
if (!remoteWantRange) throw new Error(`Remote want-range not set for ${id}`)
|
||||||
const msgIDsForThem = this.#algo.getMsgsMissing(
|
const msgIDsForThem = this.#algo.getMsgsMissing(
|
||||||
id,
|
id,
|
||||||
round,
|
round,
|
||||||
|
@ -342,7 +342,7 @@ class SyncStream extends Pipeable {
|
||||||
const goal = this.#goals.get(id)
|
const goal = this.#goals.get(id)
|
||||||
if (!goal) throw new Error(`No goal found for "${id}"`)
|
if (!goal) throw new Error(`No goal found for "${id}"`)
|
||||||
const localWantRange = this.#localWant.get(id)
|
const localWantRange = this.#localWant.get(id)
|
||||||
if (!localWantRange) throw new Error('local want-range not set')
|
if (!localWantRange) throw new Error(`Local want-range not set for ${id}`)
|
||||||
this.#requested.delete(id)
|
this.#requested.delete(id)
|
||||||
this.#localHave.delete(id)
|
this.#localHave.delete(id)
|
||||||
this.#localWant.delete(id)
|
this.#localWant.delete(id)
|
||||||
|
@ -380,7 +380,7 @@ class SyncStream extends Pipeable {
|
||||||
if (msgsForMe.length === 0) return
|
if (msgsForMe.length === 0) return
|
||||||
const goal = this.#goals.get(id)
|
const goal = this.#goals.get(id)
|
||||||
if (!goal) throw new Error(`No goal found for "${id}"`)
|
if (!goal) throw new Error(`No goal found for "${id}"`)
|
||||||
if (!localWantRange) throw new Error('local want-range not set')
|
if (!localWantRange) throw new Error(`Local want-range not set for "${id}"`)
|
||||||
try {
|
try {
|
||||||
this.#algo.commit(id, msgsForMe, goal, localWantRange)
|
this.#algo.commit(id, msgsForMe, goal, localWantRange)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Reference in New Issue