mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-04-23 03:00:50 -04:00
add isResend and tx return fields
This commit is contained in:
@@ -145,7 +145,7 @@ func (r *Layer1Relayer) CheckSubmittedMessages() error {
|
||||
return !r.messageSender.IsFull()
|
||||
})
|
||||
|
||||
isResend, err := r.messageSender.LoadOrResendTx(
|
||||
isResend, tx, err := r.messageSender.LoadOrResendTx(
|
||||
msg.GetTxHash(),
|
||||
msg.GetSender(),
|
||||
msg.GetNonce(),
|
||||
@@ -159,7 +159,7 @@ func (r *Layer1Relayer) CheckSubmittedMessages() error {
|
||||
log.Error("failed to load or send l1 submitted tx", "msg hash", msg.ID, "is resend", isResend, "err", err)
|
||||
return err
|
||||
}
|
||||
log.Info("")
|
||||
log.Info("successfully check l1 submitted tx", "resend", isResend, "tx.Hash", tx.Hash().String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ func (r *Layer2Relayer) CheckSubmittedMessages() error {
|
||||
return !r.messageSender.IsFull()
|
||||
})
|
||||
|
||||
isResend, err := r.messageSender.LoadOrResendTx(
|
||||
isResend, tx, err := r.messageSender.LoadOrResendTx(
|
||||
msg.GetTxHash(),
|
||||
msg.GetSender(),
|
||||
msg.GetNonce(),
|
||||
@@ -194,6 +194,7 @@ func (r *Layer2Relayer) CheckSubmittedMessages() error {
|
||||
log.Error("failed to load or send l2 submitted tx", "msg.hash", msg.ID, "err", err)
|
||||
return err
|
||||
}
|
||||
log.Info("successfully check l2 submitted tx", "resend", isResend, "tx.Hash", tx.Hash().String())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -455,7 +456,7 @@ func (r *Layer2Relayer) CheckRollupBatches(rollupStatus types.RollupStatus) erro
|
||||
return !r.rollupSender.IsFull()
|
||||
})
|
||||
|
||||
isResend, err := r.rollupSender.LoadOrResendTx(
|
||||
isResend, tx, err := r.rollupSender.LoadOrResendTx(
|
||||
msg.GetTxHash(),
|
||||
msg.GetSender(),
|
||||
msg.GetNonce(),
|
||||
@@ -469,7 +470,7 @@ func (r *Layer2Relayer) CheckRollupBatches(rollupStatus types.RollupStatus) erro
|
||||
log.Error("failed to load or send rollup tx", "batch hash", msg.ID, "rollup status", rollupStatus, "err", err)
|
||||
return err
|
||||
}
|
||||
log.Info("")
|
||||
log.Info("successfully check rollup batch tx", "resend", isResend, "tx.Hash", tx.Hash().String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,15 +199,15 @@ func (s *Sender) getTransaction(txHash common.Hash) (*types.Transaction, uint64,
|
||||
}
|
||||
|
||||
// LoadOrResendTx load or resend tx, if it's resend the first return value is true.
|
||||
func (s *Sender) LoadOrResendTx(destTxHash common.Hash, sender common.Address, nonce uint64, ID string, target *common.Address, value *big.Int, data []byte, minGasLimit uint64) (bool, error) {
|
||||
func (s *Sender) LoadOrResendTx(destTxHash common.Hash, sender common.Address, nonce uint64, ID string, target *common.Address, value *big.Int, data []byte, minGasLimit uint64) (bool, *types.Transaction, error) {
|
||||
tx, number, errTx := s.getTransaction(destTxHash)
|
||||
// check error except `not found` kind of tx.
|
||||
if errTx != nil && errTx.Error() != "not found" {
|
||||
return false, errTx
|
||||
return false, nil, errTx
|
||||
}
|
||||
// We occupy the ID, in case some other threads call with the same ID in the same time
|
||||
if ok := s.pendingTxs.SetIfAbsent(ID, nil); !ok {
|
||||
return false, fmt.Errorf("pending pool has repeat ID, ID: %s", ID)
|
||||
return false, nil, fmt.Errorf("pending pool has repeat ID, ID: %s", ID)
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -223,13 +223,13 @@ func (s *Sender) LoadOrResendTx(destTxHash common.Hash, sender common.Address, n
|
||||
auth := s.auths.accounts[sender]
|
||||
feeData, err2Ld = s.getFeeData(auth, target, value, data, minGasLimit)
|
||||
if err2Ld != nil {
|
||||
return false, err2Ld
|
||||
return false, nil, err2Ld
|
||||
}
|
||||
// If tx is not in chain node, create and resend it.
|
||||
if errTx != nil {
|
||||
tx, err2Ld = s.createAndSendTx(auth, feeData, target, value, data, &nonce)
|
||||
if err2Ld != nil {
|
||||
return false, err2Ld
|
||||
return false, nil, err2Ld
|
||||
}
|
||||
isResend = true
|
||||
}
|
||||
@@ -240,7 +240,7 @@ func (s *Sender) LoadOrResendTx(destTxHash common.Hash, sender common.Address, n
|
||||
signer: auth,
|
||||
tx: tx,
|
||||
})
|
||||
return isResend, nil
|
||||
return isResend, tx, nil
|
||||
}
|
||||
|
||||
// SendTransaction send a signed L2tL1 transaction.
|
||||
|
||||
Reference in New Issue
Block a user