Skip to content

Commit 4a11fd1

Browse files
authored
Merge pull request #1036 from lightninglabs/rename-chain-porter-states
Improve Clarity in ChainPorter State Names
2 parents 7035ded + 0647401 commit 4a11fd1

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

itest/psbt_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2968,7 +2968,7 @@ func testPsbtRelativeLockTimeSendProofFail(t *harnessTest) {
29682968

29692969
AssertSendEvents(
29702970
t.t, aliceScriptKeyBytes, sendEvents,
2971-
tapfreighter.SendStateLogCommit,
2971+
tapfreighter.SendStateStorePreBroadcast,
29722972
tapfreighter.SendStateWaitTxConf,
29732973
)
29742974

tapfreighter/chain_porter.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ func (p *ChainPorter) storeProofs(sendPkg *sendPackage) error {
443443
log.Debugf("Not updating proofs as there are no active " +
444444
"transfers")
445445

446-
sendPkg.SendState = SendStateReceiverProofTransfer
446+
sendPkg.SendState = SendStateTransferProofs
447447
return nil
448448
}
449449

@@ -532,7 +532,7 @@ func (p *ChainPorter) storeProofs(sendPkg *sendPackage) error {
532532
}
533533
}
534534

535-
sendPkg.SendState = SendStateReceiverProofTransfer
535+
sendPkg.SendState = SendStateTransferProofs
536536
return nil
537537
}
538538

@@ -1031,16 +1031,16 @@ func (p *ChainPorter) stateStep(currentPkg sendPackage) (*sendPackage, error) {
10311031
"package: %w", err)
10321032
}
10331033

1034-
currentPkg.SendState = SendStateLogCommit
1034+
currentPkg.SendState = SendStateStorePreBroadcast
10351035

10361036
return &currentPkg, nil
10371037

1038-
// At this state, we have a final PSBT transaction which is fully
1039-
// signed. We'll write this to disk (the point of no return), then
1040-
// broadcast this to the network.
1041-
case SendStateLogCommit:
1042-
// Before we can broadcast, we want to find out the current
1043-
// height to pass as a height hint.
1038+
// In this state, the parcel state is stored before the fully signed
1039+
// transaction is broadcast to the mempool.
1040+
case SendStateStorePreBroadcast:
1041+
// We won't broadcast in this state, but in preparation for
1042+
// broadcasting, we will find out the current height to use as
1043+
// a height hint.
10441044
ctx, cancel := p.WithCtxQuit()
10451045
defer cancel()
10461046
currentHeight, err := p.cfg.ChainBridge.CurrentHeight(ctx)
@@ -1164,8 +1164,8 @@ func (p *ChainPorter) stateStep(currentPkg sendPackage) (*sendPackage, error) {
11641164

11651165
// At this point, the transfer transaction is confirmed on-chain, and
11661166
// we've stored the sender and receiver proofs in the proof archive.
1167-
// We'll now attempt to transfer the receiver proof to the receiver.
1168-
case SendStateReceiverProofTransfer:
1167+
// We'll now attempt to transfer one or more proofs to the receiver(s).
1168+
case SendStateTransferProofs:
11691169
// We'll set the package state to complete early here so the
11701170
// main loop breaks out. We'll continue to attempt proof
11711171
// deliver in the background.
@@ -1181,7 +1181,7 @@ func (p *ChainPorter) stateStep(currentPkg sendPackage) (*sendPackage, error) {
11811181
"proof: %v", err)
11821182

11831183
p.publishSubscriberEvent(newAssetSendErrorEvent(
1184-
err, SendStateReceiverProofTransfer,
1184+
err, SendStateTransferProofs,
11851185
currentPkg,
11861186
))
11871187
}

tapfreighter/parcel.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@ const (
3838
// then finalize to place the necessary signatures in the transaction.
3939
SendStateAnchorSign
4040

41-
// SendStateLogCommit is the final in memory state. In this state,
42-
// we'll extract the signed transaction from the PSBT and log the
43-
// transfer information to disk. At this point, after a restart, the
44-
// transfer can be resumed.
45-
SendStateLogCommit
41+
// SendStateStorePreBroadcast is the state in which the finalized fully
42+
// signed transaction is written to persistent storage before broadcast.
43+
SendStateStorePreBroadcast
4644

4745
// SendStateBroadcast broadcasts the transfer transaction to the
4846
// network, and imports the taproot output back into the wallet to
@@ -57,9 +55,9 @@ const (
5755
// and receiver proofs to the proof archive.
5856
SendStateStoreProofs
5957

60-
// SendStateReceiverProofTransfer is the state in which we will commence
61-
// the receiver proof transfer process.
62-
SendStateReceiverProofTransfer
58+
// SendStateTransferProofs is the state where we attempt to transfer
59+
// on-chain transaction proof(s) to the receiving party or parties.
60+
SendStateTransferProofs
6361

6462
// SendStateComplete is the state which is reached once entire asset
6563
// transfer process is complete.
@@ -78,8 +76,8 @@ func (s SendState) String() string {
7876
case SendStateAnchorSign:
7977
return "SendStateAnchorSign"
8078

81-
case SendStateLogCommit:
82-
return "SendStateLogCommit"
79+
case SendStateStorePreBroadcast:
80+
return "SendStateStorePreBroadcast"
8381

8482
case SendStateBroadcast:
8583
return "SendStateBroadcast"
@@ -90,8 +88,8 @@ func (s SendState) String() string {
9088
case SendStateStoreProofs:
9189
return "SendStateStoreProofs"
9290

93-
case SendStateReceiverProofTransfer:
94-
return "SendStateReceiverProofTransfer"
91+
case SendStateTransferProofs:
92+
return "SendStateTransferProofs"
9593

9694
case SendStateComplete:
9795
return "SendStateComplete"
@@ -381,7 +379,7 @@ func (p *PreAnchoredParcel) pkg() *sendPackage {
381379
// commitment.
382380
return &sendPackage{
383381
Parcel: p,
384-
SendState: SendStateLogCommit,
382+
SendState: SendStateStorePreBroadcast,
385383
VirtualPackets: p.virtualPackets,
386384
PassiveAssets: p.passiveAssets,
387385
AnchorTx: p.anchorTx,

0 commit comments

Comments
 (0)