Skip to content

Commit cb15607

Browse files
committed
tapdb: upsert pre-commit when inserting supply commit
A supply pre-commit may have been discovered (via supply leaves) when fetching its corresponding supply commit, meaning it might not yet exist in the database. To avoid missing data, upsert the pre-commit at the time the supply commit is inserted.
1 parent 215fc5f commit cb15607

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tapdb/supply_commit.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,12 @@ func (s *SupplyCommitMachine) InsertSupplyCommit(ctx context.Context,
11511151
"pre-commit outpoint: %w", err)
11521152
}
11531153

1154+
err = upsertSupplyPreCommit(ctx, db, preCommit)
1155+
if err != nil {
1156+
return fmt.Errorf("failed to upsert "+
1157+
"pre-commit: %w", err)
1158+
}
1159+
11541160
markParams := sqlc.MarkPreCommitSpentByOutpointParams{
11551161
SpentByCommitID: sqlInt64(newCommitmentID),
11561162
Outpoint: outpointBytes,

0 commit comments

Comments
 (0)