Skip to content

Commit

Permalink
Merge pull request #2469 from iotaledger/fix/block-chaining
Browse files Browse the repository at this point in the history
Fix the block chaining if the tx was published on L1
  • Loading branch information
muXxer authored May 12, 2023
2 parents e1e3dbb + 0fc4e96 commit 621eafe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/nodeconn/nodeconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ func (nc *nodeConnection) checkReceivedTxPendingAndCancelPoW(block *iotago.Block
// check if the block was already referenced
if metadata.ReferencedByMilestoneIndex != 0 {
// block with the tracked tx already got referenced, we can abort attachment of the tx
pendingTx.SetPublished()
pendingTx.SetPublished(blockID)
break
}

Expand All @@ -568,7 +568,7 @@ func (nc *nodeConnection) checkReceivedTxPendingAndCancelPoW(block *iotago.Block

// block is solid and the quality of the tips seem fine
// => abort our own attachment
pendingTx.SetPublished()
pendingTx.SetPublished(blockID)
break
}
}()
Expand Down
6 changes: 5 additions & 1 deletion packages/nodeconn/pending_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ func (tx *pendingTransaction) propagateReattach() {
}
}

func (tx *pendingTransaction) SetPublished() {
func (tx *pendingTransaction) SetPublished(blockID iotago.BlockID) {
// we can set the blockID of the pendingTransaction here, so the chaining will use the block that was published on L1.
// we can even overwrite this blockID several times if there are multiple blocks published with the same pendingTransaction on L1,
// since it doesn't matter where we attach our next Tx, as long as the chain structure is valid.
tx.SetBlockID(blockID)
tx.cancelCtxPublished()
}

Expand Down

0 comments on commit 621eafe

Please sign in to comment.