Make cpfp db save operations atomic

This commit is contained in:
Mononaut
2023-06-22 11:52:43 -04:00
parent 9ff5ce0d37
commit 1f442b9ea6
4 changed files with 65 additions and 62 deletions

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
}
}
}