@secondlayer/subgraphs 3.14.1 → 3.14.3
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/src/index.js +17 -12
- package/dist/src/index.js.map +4 -4
- package/dist/src/runtime/block-processor.js +17 -12
- package/dist/src/runtime/block-processor.js.map +4 -4
- package/dist/src/runtime/catchup.js +17 -12
- package/dist/src/runtime/catchup.js.map +4 -4
- package/dist/src/runtime/context.js +10 -9
- package/dist/src/runtime/context.js.map +3 -3
- package/dist/src/runtime/processor.js +17 -12
- package/dist/src/runtime/processor.js.map +4 -4
- package/dist/src/runtime/reindex.js +17 -12
- package/dist/src/runtime/reindex.js.map +4 -4
- package/dist/src/runtime/reorg.js +17 -12
- package/dist/src/runtime/reorg.js.map +4 -4
- package/dist/src/service.js +17 -12
- package/dist/src/service.js.map +4 -4
- package/package.json +2 -2
|
@@ -520,21 +520,22 @@ class SubgraphContext {
|
|
|
520
520
|
"_tx_id",
|
|
521
521
|
"_created_at"
|
|
522
522
|
];
|
|
523
|
-
|
|
524
|
-
|
|
523
|
+
if (this.journal) {
|
|
524
|
+
statements.push(this.journalCaptureSQL(batch.table, batch.keyCols, Array.from(batch.rows.values()).map((r) => batch.keyCols.map((k) => escapeLiteral(r.keys[k])))));
|
|
525
|
+
}
|
|
526
|
+
for (const r of batch.rows.values()) {
|
|
527
|
+
const keyPred = batch.keyCols.map((k) => `"${k}" = ${escapeLiteral(r.keys[k])}`).join(" AND ");
|
|
528
|
+
const updSet = batch.deltaCols.map((c) => `"${c}" = COALESCE("${c}", 0) + (${String(r.deltas[c] ?? 0n)})`).join(", ");
|
|
529
|
+
statements.push(`UPDATE ${qualifiedTable} SET ${updSet} WHERE ${keyPred}`);
|
|
530
|
+
const insertVals = [
|
|
525
531
|
...batch.keyCols.map((k) => escapeLiteral(r.keys[k])),
|
|
526
532
|
...batch.deltaCols.map((c) => String(r.deltas[c] ?? 0n)),
|
|
527
533
|
escapeLiteral(r.meta.blockHeight),
|
|
528
534
|
escapeLiteral(r.meta.txId),
|
|
529
535
|
"NOW()"
|
|
530
536
|
];
|
|
531
|
-
|
|
532
|
-
}).join(", ");
|
|
533
|
-
const setClauses = batch.deltaCols.map((c) => `"${c}" = COALESCE("${batch.table}"."${c}", 0) + EXCLUDED."${c}"`);
|
|
534
|
-
if (this.journal) {
|
|
535
|
-
statements.push(this.journalCaptureSQL(batch.table, batch.keyCols, Array.from(batch.rows.values()).map((r) => batch.keyCols.map((k) => escapeLiteral(r.keys[k])))));
|
|
537
|
+
statements.push(`INSERT INTO ${qualifiedTable} (${cols.map((c) => `"${c}"`).join(", ")}) ` + `SELECT ${insertVals.join(", ")} ` + `WHERE NOT EXISTS (SELECT 1 FROM ${qualifiedTable} WHERE ${keyPred})`);
|
|
536
538
|
}
|
|
537
|
-
statements.push(`INSERT INTO ${qualifiedTable} (${cols.map((c) => `"${c}"`).join(", ")}) VALUES ${valuesList} ` + `ON CONFLICT (${batch.keyCols.map((k) => `"${k}"`).join(", ")}) DO UPDATE SET ${setClauses.join(", ")}`);
|
|
538
539
|
incBatch = null;
|
|
539
540
|
incBatchKey = "";
|
|
540
541
|
};
|
|
@@ -1335,6 +1336,7 @@ import { resolveTraitContractIds } from "@secondlayer/shared/db/queries/contract
|
|
|
1335
1336
|
import { advanceOperationCursor } from "@secondlayer/shared/db/queries/subgraph-operations";
|
|
1336
1337
|
import {
|
|
1337
1338
|
isByoSubgraph,
|
|
1339
|
+
recordLiveProgress,
|
|
1338
1340
|
recordSubgraphProcessed,
|
|
1339
1341
|
resolveSubgraphDb,
|
|
1340
1342
|
updateSubgraphStatus
|
|
@@ -2029,7 +2031,7 @@ async function processBlock(subgraph, subgraphName, blockHeight, opts) {
|
|
|
2029
2031
|
result.matched = matched.length;
|
|
2030
2032
|
if (matched.length === 0) {
|
|
2031
2033
|
if (!opts?.skipProgressUpdate) {
|
|
2032
|
-
await
|
|
2034
|
+
await recordLiveProgress(targetDb, subgraphName, blockHeight);
|
|
2033
2035
|
}
|
|
2034
2036
|
return result;
|
|
2035
2037
|
}
|
|
@@ -2052,8 +2054,11 @@ async function processBlock(subgraph, subgraphName, blockHeight, opts) {
|
|
|
2052
2054
|
const applyProgress = async (tx, rr) => {
|
|
2053
2055
|
if (opts?.skipProgressUpdate)
|
|
2054
2056
|
return;
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
+
if (rr.errors > 0 && rr.processed === 0) {
|
|
2058
|
+
await updateSubgraphStatus(tx, subgraphName, "error", blockHeight);
|
|
2059
|
+
} else {
|
|
2060
|
+
await recordLiveProgress(tx, subgraphName, blockHeight);
|
|
2061
|
+
}
|
|
2057
2062
|
if (rr.processed > 0 || rr.errors > 0) {
|
|
2058
2063
|
const lastError = rr.errors > 0 ? `${rr.errors} error(s) at block ${blockHeight}` : undefined;
|
|
2059
2064
|
await recordSubgraphProcessed(tx, subgraphName, rr.processed, rr.errors, lastError);
|
|
@@ -2756,5 +2761,5 @@ export {
|
|
|
2756
2761
|
backfillSubgraph
|
|
2757
2762
|
};
|
|
2758
2763
|
|
|
2759
|
-
//# debugId=
|
|
2764
|
+
//# debugId=7723AA51218664DB64756E2164756E21
|
|
2760
2765
|
//# sourceMappingURL=reindex.js.map
|