Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/check-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ on:
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
check-code:
name: Check Code
runs-on: ubuntu-latest
timeout-minutes: 25
permissions:
id-token: write
contents: read
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ on:
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
integration:
name: End to End Test
runs-on: ubuntu-latest
timeout-minutes: 25
permissions:
id-token: write
contents: read
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ on:
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
integration:
name: Integration Test
runs-on: ubuntu-latest
timeout-minutes: 25
permissions:
id-token: write
contents: read
Expand Down
27 changes: 18 additions & 9 deletions src/batch/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ pub struct BatchInfo {
pub created_ledger_tx_id: LedgerTxId,
}

pub struct BatchBroadcastLedgerTx<'a> {
pub tx: Transaction<'a, Postgres>,
pub batch_info: BatchInfo,
pub ledger_tx_id: LedgerTxId,
pub(crate) was_newly_set: bool,
}

#[derive(Debug, Clone)]
pub struct Batches {
pool: PgPool,
Expand Down Expand Up @@ -255,7 +262,7 @@ impl Batches {
&self,
bitcoin_tx_id: bitcoin::Txid,
wallet_id: WalletId,
) -> Result<Option<(Transaction<'_, Postgres>, BatchInfo, LedgerTxId)>, BatchError> {
) -> Result<Option<BatchBroadcastLedgerTx<'_>>, BatchError> {
let mut tx = self.pool.begin().await?;
let row = sqlx::query!(
r#"WITH b AS (
Expand Down Expand Up @@ -284,15 +291,16 @@ impl Batches {
let batch_id = BatchId::from(row.id);
let payout_queue_id = PayoutQueueId::from(row.payout_queue_id);
if let Some(ledger_id) = row.ledger_id {
return Ok(Some((
return Ok(Some(BatchBroadcastLedgerTx {
tx,
BatchInfo {
batch_info: BatchInfo {
id: batch_id,
payout_queue_id,
created_ledger_tx_id,
},
LedgerTxId::from(ledger_id),
)));
ledger_tx_id: LedgerTxId::from(ledger_id),
was_newly_set: false,
}));
}
let ledger_transaction_id = LedgerTxId::new();
sqlx::query!(
Expand All @@ -307,15 +315,16 @@ impl Batches {
.execute(&mut *tx)
.await?;

Ok(Some((
Ok(Some(BatchBroadcastLedgerTx {
tx,
BatchInfo {
batch_info: BatchInfo {
id: batch_id,
payout_queue_id,
created_ledger_tx_id,
},
ledger_transaction_id,
)))
ledger_tx_id: ledger_transaction_id,
was_newly_set: true,
}))
}

#[instrument(name = "batches.set_batch_cancel_ledger_tx_id", skip(self))]
Expand Down
Loading
Loading