@@ -146,13 +146,13 @@ func (b *Batch) NewPendingTransaction(tx *txtypes.Transaction, txRaw []byte, rec
146
146
// b) has enough balance at the senders account in order to pay the
147
147
// tansactions gas fees, also considering all previous locally
148
148
// included transactions in that batch
149
- func (b * Batch ) ValidateTx (ctx context.Context , p * PendingTransaction ) ( bool , error ) {
149
+ func (b * Batch ) ValidateTx (ctx context.Context , p * PendingTransaction ) error {
150
150
currentNonce , err := b .state .GetNonce (ctx , p .sender )
151
151
if err != nil {
152
- return false , err
152
+ return err
153
153
}
154
154
if p .tx .Nonce () != currentNonce {
155
- return false , errors .Errorf ("nonce mismatch, want: %d,got: %d" , currentNonce , p .tx .Nonce ())
155
+ return errors .Errorf ("nonce mismatch, want: %d,got: %d" , currentNonce , p .tx .Nonce ())
156
156
}
157
157
158
158
if err := ValidateGasParams (p .tx , b .block .BaseFee ()); err != nil {
@@ -162,40 +162,40 @@ func (b *Batch) ValidateTx(ctx context.Context, p *PendingTransaction) (bool, er
162
162
p .minerFee = CalculatePriorityFee (p .tx , b .block .BaseFee ())
163
163
balance , err := b .state .GetBalance (ctx , p .sender )
164
164
if err != nil {
165
- return false , err
165
+ return err
166
166
}
167
167
if balance .Cmp (p .gasCost ) < 0 {
168
- return false , errors .New ("not enough funds to pay gas fee" )
168
+ return errors .New ("not enough funds to pay gas fee" )
169
169
}
170
- return true , nil
170
+ return nil
171
171
}
172
172
173
173
// ApplyTx will include the transaction `p` in the local batch-state and
174
174
// will modify the batches local state to include the nonce and balance changes.
175
175
// ApplyTx can fail when the transaction's inclusion would surpass the batches
176
176
// gas limit.
177
- func (b * Batch ) ApplyTx (ctx context.Context , p * PendingTransaction ) ( bool , error ) {
177
+ func (b * Batch ) ApplyTx (ctx context.Context , p * PendingTransaction ) error {
178
178
b .mux .Lock ()
179
179
defer b .mux .Unlock ()
180
180
181
181
err := b .gasPool .SubGas (p .tx .Gas ())
182
182
if err != nil {
183
183
// gas limit reached
184
- return false , err
184
+ return err
185
185
}
186
186
err = b .state .SubBalance (ctx , p .sender , p .gasCost )
187
187
if err != nil {
188
- return false , err
188
+ return err
189
189
}
190
190
// not really necessary, only to e.g. observe the total gained fee
191
191
err = b .state .AddBalance (ctx , b .block .Coinbase (), p .minerFee )
192
192
if err != nil {
193
- return false , err
193
+ return err
194
194
}
195
195
b .state .SetNonce (p .sender , p .tx .Nonce ()+ 1 )
196
196
197
197
b .transactions .Enqueue (p )
198
- return true , nil
198
+ return nil
199
199
}
200
200
201
201
func (b * Batch ) Transactions () * TransactionQueue {
0 commit comments