(proofID int64)
| 232 | } |
| 233 | |
| 234 | func triggerRevalidate(proofID int64) error { |
| 235 | switch common.CurrentRuntime { |
| 236 | case common.Runtimes.Standalone: |
| 237 | // Revalidate it in a block way since this func will |
| 238 | // be called under goroutine. |
| 239 | // FIXME: basiclly duplicated to `cmd/lambda_worker.revalidate_single()` |
| 240 | proof := model.Proof{} |
| 241 | tx := model.DB.Preload("ProofChain").Preload("ProofChain.Previous").Where("id = ?", proofID).First(&proof) |
| 242 | if tx.Error != nil { |
| 243 | return xerrors.Errorf("%w", tx.Error) |
| 244 | } |
| 245 | return proof.Revalidate() |
| 246 | case common.Runtimes.Lambda: |
| 247 | // Use AWS SQS to send message to workers |
| 248 | msg := types.QueueMessage{ |
| 249 | Action: types.QueueActions.Revalidate, |
| 250 | ProofID: proofID, |
| 251 | } |
| 252 | |
| 253 | if err := sqs.Send(msg); err != nil { |
| 254 | return xerrors.Errorf("Failed to send message to queue: %w", err) |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | return nil |
| 259 | } |
no test coverage detected