@pkcprotocol/pkc-js 0.0.156 → 0.0.157
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/dist/browser/clients/base-client-manager.js +10 -1
- package/dist/browser/clients/base-client-manager.js.map +1 -1
- package/dist/browser/clients/shared-pubsub-topic-list.d.ts +14 -0
- package/dist/browser/clients/shared-pubsub-topic-list.js +61 -0
- package/dist/browser/clients/shared-pubsub-topic-list.js.map +1 -0
- package/dist/browser/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/browser/runtime/node/community/db-handler.d.ts +2 -0
- package/dist/browser/runtime/node/community/db-handler.js +23 -9
- package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.d.ts +6 -0
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.js +49 -10
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/lifecycle.js +102 -61
- package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/pubsub.js +11 -4
- package/dist/browser/runtime/node/community/local-community/pubsub.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.d.ts +22 -4
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js +45 -9
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community.d.ts +1 -0
- package/dist/browser/runtime/node/community/local-community.js +5 -0
- package/dist/browser/runtime/node/community/local-community.js.map +1 -1
- package/dist/browser/runtime/node/event-loop-watch.d.ts +13 -0
- package/dist/browser/runtime/node/event-loop-watch.js +58 -0
- package/dist/browser/runtime/node/event-loop-watch.js.map +1 -0
- package/dist/bundled/bundle-manifest.json +56 -53
- package/dist/bundled/challenges.js +1 -1
- package/dist/bundled/chunks/{helia-for-pkc-CceaAEzV.js → helia-for-pkc-BT2UmDem.js} +2 -2
- package/dist/bundled/chunks/{local-community-C8Qwak8F.js → local-community-BexngGU7.js} +1 -1
- package/dist/bundled/chunks/{local-community-BzZbcwm-.js → local-community-oqjqTa9T.js} +221 -71
- package/dist/bundled/chunks/{node-CleFjKjX.js → node-CvXtQ-4A.js} +5 -5
- package/dist/bundled/chunks/{page-sort-scoring-BAl6dNeR.js → page-sort-scoring-VN_GGInQ.js} +1 -1
- package/dist/bundled/chunks/{rpc-local-community-CW6GnMsd.js → rpc-local-community-BjIHRbYy.js} +51 -4
- package/dist/bundled/chunks/{util-C29b1mlK.js → util-Bu3ItQsN.js} +1 -1
- package/dist/bundled/chunks/{util-C0MpIK71.js → util-DDsWXOtP.js} +1 -1
- package/dist/bundled/chunks/{validate-package-factories-CAwF_8n6.js → validate-package-factories-CmJt781W.js} +2 -2
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/page-sorts.js +1 -1
- package/dist/bundled/rpc/src/index.js +4 -4
- package/dist/node/clients/base-client-manager.js +10 -1
- package/dist/node/clients/base-client-manager.js.map +1 -1
- package/dist/node/clients/shared-pubsub-topic-list.d.ts +14 -0
- package/dist/node/clients/shared-pubsub-topic-list.js +61 -0
- package/dist/node/clients/shared-pubsub-topic-list.js.map +1 -0
- package/dist/node/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/dist/node/runtime/node/community/db-handler.d.ts +2 -0
- package/dist/node/runtime/node/community/db-handler.js +23 -9
- package/dist/node/runtime/node/community/db-handler.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/ipns-publishing.d.ts +6 -0
- package/dist/node/runtime/node/community/local-community/ipns-publishing.js +49 -10
- package/dist/node/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/lifecycle.js +102 -61
- package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/pubsub.js +11 -4
- package/dist/node/runtime/node/community/local-community/pubsub.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.d.ts +22 -4
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js +45 -9
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
- package/dist/node/runtime/node/community/local-community.d.ts +1 -0
- package/dist/node/runtime/node/community/local-community.js +5 -0
- package/dist/node/runtime/node/community/local-community.js.map +1 -1
- package/dist/node/runtime/node/event-loop-watch.d.ts +13 -0
- package/dist/node/runtime/node/event-loop-watch.js +58 -0
- package/dist/node/runtime/node/event-loop-watch.js.map +1 -0
- package/package.json +1 -1
|
@@ -52,11 +52,21 @@ function deriveAliasOriginalAuthorSignerAddress(originalAuthorPublicKey) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
export class DbHandler {
|
|
55
|
+
// Every method that writes a publication (a vote, comment, edit, moderation, an approval, a purge) calls this.
|
|
56
|
+
// Besides dropping what was memoized from the old rows, it asks the community for a new record, which wakes its
|
|
57
|
+
// publish loop: the loop does not poll the DB for changes (issue #576). A write inside readBackWithoutStoring is
|
|
58
|
+
// rolled back, so it still drops the memo (the rows did change for the read that follows) but asks for no record.
|
|
59
|
+
_notePublicationWrite() {
|
|
60
|
+
this._publicationWriteGeneration++;
|
|
61
|
+
if (this._community && this._readBackWithoutStoringDepth === 0)
|
|
62
|
+
this._community._communityUpdateTrigger = true;
|
|
63
|
+
}
|
|
55
64
|
constructor(community) {
|
|
56
65
|
this._transactionGeneration = 0;
|
|
57
66
|
// Advanced by every write to the publication tables (comments, votes, edits, moderations, aliases, purges). The
|
|
58
67
|
// update cycle's author memo (CommunityAuthorMemo) is only reused while it stays the same.
|
|
59
68
|
this._publicationWriteGeneration = 0;
|
|
69
|
+
this._readBackWithoutStoringDepth = 0;
|
|
60
70
|
// The address this handler has claimed the start of, from lockCommunityStart until unlockCommunityStart
|
|
61
71
|
this._startLockAddress = undefined;
|
|
62
72
|
this._community = community;
|
|
@@ -237,11 +247,15 @@ export class DbHandler {
|
|
|
237
247
|
// no transaction open (issue #417).
|
|
238
248
|
readBackWithoutStoring(opts) {
|
|
239
249
|
this._db.exec("SAVEPOINT read_back_without_storing");
|
|
250
|
+
this._readBackWithoutStoringDepth++;
|
|
240
251
|
try {
|
|
241
252
|
opts.write();
|
|
242
253
|
return opts.read();
|
|
243
254
|
}
|
|
244
255
|
finally {
|
|
256
|
+
this._readBackWithoutStoringDepth--;
|
|
257
|
+
// what was memoized inside the savepoint was read from rows that are about to be gone
|
|
258
|
+
this._publicationWriteGeneration++;
|
|
245
259
|
this._db.exec("ROLLBACK TO read_back_without_storing");
|
|
246
260
|
this._db.exec("RELEASE read_back_without_storing");
|
|
247
261
|
}
|
|
@@ -1023,18 +1037,18 @@ export class DbHandler {
|
|
|
1023
1037
|
}
|
|
1024
1038
|
}
|
|
1025
1039
|
deleteVote(authorSignerAddress, commentCid) {
|
|
1026
|
-
this.
|
|
1040
|
+
this._notePublicationWrite();
|
|
1027
1041
|
this._db
|
|
1028
1042
|
.prepare(`DELETE FROM ${TABLES.VOTES} WHERE commentCid = ? AND authorSignerAddress = ?`)
|
|
1029
1043
|
.run(commentCid, authorSignerAddress);
|
|
1030
1044
|
}
|
|
1031
1045
|
_deleteCommentEditRow(rowid) {
|
|
1032
|
-
this.
|
|
1046
|
+
this._notePublicationWrite();
|
|
1033
1047
|
const deleteResult = this._db.prepare(`DELETE FROM ${TABLES.COMMENT_EDITS} WHERE rowid = ?`).run(rowid);
|
|
1034
1048
|
return deleteResult.changes > 0;
|
|
1035
1049
|
}
|
|
1036
1050
|
insertVotes(votes) {
|
|
1037
|
-
this.
|
|
1051
|
+
this._notePublicationWrite();
|
|
1038
1052
|
if (votes.length === 0)
|
|
1039
1053
|
return;
|
|
1040
1054
|
const processedVotes = this._processRecordsForDbBeforeInsert(votes);
|
|
@@ -1062,7 +1076,7 @@ export class DbHandler {
|
|
|
1062
1076
|
insertMany(processedVotes);
|
|
1063
1077
|
}
|
|
1064
1078
|
insertComments(comments) {
|
|
1065
|
-
this.
|
|
1079
|
+
this._notePublicationWrite();
|
|
1066
1080
|
if (comments.length === 0)
|
|
1067
1081
|
return;
|
|
1068
1082
|
const processedComments = this._processRecordsForDbBeforeInsert(comments);
|
|
@@ -1087,7 +1101,7 @@ export class DbHandler {
|
|
|
1087
1101
|
insertMany(processedComments);
|
|
1088
1102
|
}
|
|
1089
1103
|
insertPseudonymityAliases(aliases) {
|
|
1090
|
-
this.
|
|
1104
|
+
this._notePublicationWrite();
|
|
1091
1105
|
if (aliases.length === 0)
|
|
1092
1106
|
return;
|
|
1093
1107
|
const processedAliases = this._processRecordsForDbBeforeInsert(aliases).map((alias) => ({
|
|
@@ -1137,7 +1151,7 @@ export class DbHandler {
|
|
|
1137
1151
|
upsertMany(processedUpdates);
|
|
1138
1152
|
}
|
|
1139
1153
|
insertCommentModerations(moderations) {
|
|
1140
|
-
this.
|
|
1154
|
+
this._notePublicationWrite();
|
|
1141
1155
|
if (moderations.length === 0)
|
|
1142
1156
|
return;
|
|
1143
1157
|
const processedModerations = this._processRecordsForDbBeforeInsert(moderations);
|
|
@@ -1160,7 +1174,7 @@ export class DbHandler {
|
|
|
1160
1174
|
insertMany(processedModerations);
|
|
1161
1175
|
}
|
|
1162
1176
|
insertCommentEdits(edits) {
|
|
1163
|
-
this.
|
|
1177
|
+
this._notePublicationWrite();
|
|
1164
1178
|
if (edits.length === 0)
|
|
1165
1179
|
return;
|
|
1166
1180
|
const processedEdits = this._processRecordsForDbBeforeInsert(edits);
|
|
@@ -2094,7 +2108,7 @@ export class DbHandler {
|
|
|
2094
2108
|
return pick(parsed, ["signature", ...signedKeys, ...commentEditFields]);
|
|
2095
2109
|
}
|
|
2096
2110
|
removeCommentFromPendingApproval(comment) {
|
|
2097
|
-
this.
|
|
2111
|
+
this._notePublicationWrite();
|
|
2098
2112
|
const log = Logger("pkc-js:local-community:db-handler:removeCommentFromPendingApproval");
|
|
2099
2113
|
const stmt = this._db.prepare(`UPDATE ${TABLES.COMMENTS} SET pendingApproval = 0 WHERE cid = ?`);
|
|
2100
2114
|
const res = stmt.run(comment.cid);
|
|
@@ -2937,7 +2951,7 @@ export class DbHandler {
|
|
|
2937
2951
|
return allCids;
|
|
2938
2952
|
}
|
|
2939
2953
|
purgeComment(cid, isNestedCall = false) {
|
|
2940
|
-
this.
|
|
2954
|
+
this._notePublicationWrite();
|
|
2941
2955
|
const log = Logger("pkc-js:local-community:db-handler:purgeComment");
|
|
2942
2956
|
const purgedRecords = [];
|
|
2943
2957
|
const detachedPageCids = [];
|