Skip to content

Commit 64388e1

Browse files
committed
tapfreighter: provide package response in SendStateWaitTxConf
Rename deliverTxBroadcastResp to deliverOutboundPkgResp and execute it in SendStateWaitTxConf instead of SendStateBroadcast. This change allows the RequestShipment caller to unblock when skipping the anchor transaction broadcast and proceeding directly to tx confirmation wait.
1 parent 4106f69 commit 64388e1

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

tapfreighter/chain_porter.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,17 +1558,19 @@ func (p *ChainPorter) stateStep(currentPkg sendPackage) (*sendPackage, error) {
15581558
"transaction %v: %w", txHash, err)
15591559
}
15601560

1561-
// With the transaction broadcast, we'll deliver a
1562-
// notification via the transaction broadcast response channel.
1563-
currentPkg.deliverTxBroadcastResp()
1564-
15651561
// Set send state to the next state to evaluate.
15661562
currentPkg.SendState = SendStateWaitTxConf
15671563
return &currentPkg, nil
15681564

15691565
// At this point, transaction broadcast is complete. We go on to wait
15701566
// for the transfer transaction to confirm on-chain.
15711567
case SendStateWaitTxConf:
1568+
// The state machine now transitions to waiting for the transfer
1569+
// transaction to be confirmed on-chain. Before entering this
1570+
// state, we return the outbound package response to unblock the
1571+
// caller's send request.
1572+
currentPkg.deliverOutboundPkgResp()
1573+
15721574
err := p.waitForTransferTxConf(&currentPkg)
15731575
return &currentPkg, err
15741576

tapfreighter/parcel.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,9 +789,9 @@ func outputAnchor(anchorTx *tapsend.AnchorTransaction, vOut *tappsbt.VOutput,
789789
}, nil
790790
}
791791

792-
// deliverTxBroadcastResp delivers a response for the parcel back to the
792+
// deliverOutboundPkgResp delivers a response for the parcel back to the
793793
// receiver over the response channel.
794-
func (s *sendPackage) deliverTxBroadcastResp() {
794+
func (s *sendPackage) deliverOutboundPkgResp() {
795795
// Ensure that we have a response channel to deliver the response over.
796796
// We may not have one if the package send process was recommenced after
797797
// a restart.

0 commit comments

Comments
 (0)