Make cpfp db save operations atomic

This commit is contained in:
Mononaut committed 2023-06-22 12:08:47 -04:00
1 parent b15a89f676
commit 2448090546
4 files changed
+65 -62

No files matched your search

+7 -3
View File
@@ -1050,9 +1050,13 @@ class Blocks {
}
public async $saveCpfp(hash: string, height: number, cpfpSummary: CpfpSummary): Promise<void> {
const result = await cpfpRepository.$batchSaveClusters(cpfpSummary.clusters);
if (!result) {
await cpfpRepository.$insertProgressMarker(height);
try {
const result = await cpfpRepository.$batchSaveClusters(cpfpSummary.clusters);
if (!result) {
await cpfpRepository.$insertProgressMarker(height);
}
} catch (e) {
// not a fatal error, we'll try again next time the indexer runs
}
}
}