(
ex: &mut PgTransaction<'_>,
events: &[(EventIndex, Event)],
)
| 71 | |
| 72 | #[instrument(skip_all)] |
| 73 | pub async fn append( |
| 74 | ex: &mut PgTransaction<'_>, |
| 75 | events: &[(EventIndex, Event)], |
| 76 | ) -> Result<(), sqlx::Error> { |
| 77 | // TODO: there might be a more efficient way to do this like execute_many or |
| 78 | // COPY but my tests show that even if we sleep during the transaction it |
| 79 | // does not block other connections from using the database, so it's not |
| 80 | // high priority. |
| 81 | for (index, event) in events { |
| 82 | match event { |
| 83 | Event::Trade(event) => insert_trade(ex, index, event).await?, |
| 84 | Event::Invalidation(event) => insert_invalidation(ex, index, event).await?, |
| 85 | Event::Settlement(event) => insert_settlement(ex, index, event).await?, |
| 86 | Event::PreSignature(event) => insert_presignature(ex, index, event).await?, |
| 87 | }; |
| 88 | } |
| 89 | Ok(()) |
| 90 | } |
| 91 | |
| 92 | #[instrument(skip_all)] |
| 93 | async fn insert_invalidation( |
no test coverage detected