querysub 0.485.0 → 0.487.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "querysub",
3
- "version": "0.485.0",
3
+ "version": "0.487.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
@@ -89,13 +89,26 @@ class ValidStateComputer {
89
89
  }
90
90
  }
91
91
 
92
+ return true;
93
+ });
94
+
95
+ // For any value we're the authority on that we already have, swap in our own stored copy. The data
96
+ // is immutable per (path, time) — only the valid state can differ, and we own that — so we must never
97
+ // adopt a sibling authority's valid state. Remapping (rather than only skipping the re-ingest) keeps
98
+ // everything downstream (valuesChanged, dependenciesChanged) on a single object instead of a mix of
99
+ // our copy and the remote's.
100
+ pathValues = pathValues.map(value => {
101
+ if (!PathRouter.isSelfAuthority(value.path)) return value;
102
+ return authorityStorage.getValueExactMaybeRejected(value.path, value.time) || value;
103
+ });
104
+
105
+ for (let value of pathValues) {
92
106
  if (!PathRouter.isSelfAuthority(value.path)) {
93
107
  notOurValues.push(value);
94
108
  } else {
95
109
  ourValues.push(value);
96
110
  }
97
- return true;
98
- });
111
+ }
99
112
 
100
113
  // NOTE: Watch value locks, will internally watch remote locks if we aren't the authority on the values
101
114
  lockWatcher2.watchValueLocks(ourValues, now);
@@ -419,11 +432,11 @@ class ValidStateComputer {
419
432
  }
420
433
  */
421
434
  // IMPORTANT! This means if it didn't previously exist and it's presently rejected, we count that as a change, as it this is going from undefined to false. This is actually very useful, as a lot of places want to know if a write is rejected, so they can display it in the UI for the developer.
422
- if (valid === prevValidState) continue;
435
+ if (valid === prevValidState && pathValue.valid === valid) continue;
423
436
 
424
437
  // NOTE: We might remove this logging later as it's pretty heavy, but right now we still have bugs somewhere here.
425
438
  {
426
- console.info(`Changed valid state ${JSON.stringify(prevValidState)} to ${JSON.stringify(valid)}`, {
439
+ console.info(`Changed valid state ${JSON.stringify(prevValidState)} to ${JSON.stringify(valid)} (and path is ${JSON.stringify(pathValue.valid)})`, {
427
440
  path: pathValue.path,
428
441
  timeId: pathValue.time.time,
429
442
  timeIdFull: pathValue.time,