@@ -74,31 +74,41 @@ func New(journalPath string, journalTime time.Duration, chainConfig *params.Chai
74
74
75
75
// Track adds a transaction to the tracked set.
76
76
// Note: blob-type transactions are ignored.
77
- func (tracker * TxTracker ) Track (tx * types.Transaction ) {
78
- tracker .TrackAll ([]* types.Transaction {tx })
77
+ func (tracker * TxTracker ) Track (tx * types.Transaction ) error {
78
+ return tracker .TrackAll ([]* types.Transaction {tx })[ 0 ]
79
79
}
80
80
81
81
// TrackAll adds a list of transactions to the tracked set.
82
82
// Note: blob-type transactions are ignored.
83
- func (tracker * TxTracker ) TrackAll (txs []* types.Transaction ) {
83
+ func (tracker * TxTracker ) TrackAll (txs []* types.Transaction ) [] error {
84
84
tracker .mu .Lock ()
85
85
defer tracker .mu .Unlock ()
86
86
87
+ var errors []error
87
88
for _ , tx := range txs {
88
89
if tx .Type () == types .BlobTxType {
90
+ errors = append (errors , nil )
89
91
continue
90
92
}
91
93
// Ignore the transactions which are failed for fundamental
92
94
// validation such as invalid parameters.
93
- if tracker .pool .ValidateTxBasics (tx ) != nil {
95
+ if err := tracker .pool .ValidateTxBasics (tx ); err != nil {
96
+ log .Debug ("Invalid transaction submitted" , "hash" , tx .Hash (), "err" , err )
97
+ errors = append (errors , err )
94
98
continue
95
99
}
96
100
// If we're already tracking it, it's a no-op
97
101
if _ , ok := tracker .all [tx .Hash ()]; ok {
102
+ errors = append (errors , nil )
98
103
continue
99
104
}
105
+ // Theoretically, checking the error here is unnecessary since sender recovery
106
+ // is already part of basic validation. However, retrieving the sender address
107
+ // from the transaction cache is effectively a no-op if it was previously verified.
108
+ // Therefore, the error is still checked just in case.
100
109
addr , err := types .Sender (tracker .signer , tx )
101
- if err != nil { // Ignore this tx
110
+ if err != nil {
111
+ errors = append (errors , err )
102
112
continue
103
113
}
104
114
tracker .all [tx .Hash ()] = tx
@@ -112,6 +122,7 @@ func (tracker *TxTracker) TrackAll(txs []*types.Transaction) {
112
122
}
113
123
}
114
124
localGauge .Update (int64 (len (tracker .all )))
125
+ return errors
115
126
}
116
127
117
128
// recheck checks and returns any transactions that needs to be resubmitted.
0 commit comments