querysub 0.486.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.486.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);
@@ -182,9 +195,7 @@ class ValidStateComputer {
182
195
  }
183
196
 
184
197
  authorityStorage.ingestValues(notOurValues, { doNotArchive });
185
- let newOurValues = ourValues.filter(x => !authorityStorage.getValueExactMaybeRejected(x.path, x.time));
186
- // Only ingest the values that are new to us. Otherwise, we'd be accepting the valid state from somebody else, and we're the authority, so we just shouldn't do that.
187
- authorityStorage.ingestValues(newOurValues, { doNotArchive });
198
+ authorityStorage.ingestValues(ourValues, { doNotArchive });
188
199
 
189
200
 
190
201
  let loopCount = 0;