Skip to content

Commit d81c9d9

Browse files
accounts/abi/bind/backends: reverted some stylistic changes (#21535)
1 parent 8d35b1e commit d81c9d9

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

accounts/abi/bind/backends/simulated.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func (b *SimulatedBackend) StorageAt(ctx context.Context, contract common.Addres
195195
}
196196

197197
// TransactionReceipt returns the receipt of a transaction.
198-
func (b *SimulatedBackend) TransactionReceipt(_ context.Context, txHash common.Hash) (*types.Receipt, error) {
198+
func (b *SimulatedBackend) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) {
199199
b.mu.Lock()
200200
defer b.mu.Unlock()
201201

@@ -207,7 +207,7 @@ func (b *SimulatedBackend) TransactionReceipt(_ context.Context, txHash common.H
207207
// blockchain. The isPending return value indicates whether the transaction has been
208208
// mined yet. Note that the transaction may not be part of the canonical chain even if
209209
// it's not pending.
210-
func (b *SimulatedBackend) TransactionByHash(_ context.Context, txHash common.Hash) (*types.Transaction, bool, error) {
210+
func (b *SimulatedBackend) TransactionByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error) {
211211
b.mu.Lock()
212212
defer b.mu.Unlock()
213213

@@ -223,7 +223,7 @@ func (b *SimulatedBackend) TransactionByHash(_ context.Context, txHash common.Ha
223223
}
224224

225225
// BlockByHash retrieves a block based on the block hash.
226-
func (b *SimulatedBackend) BlockByHash(_ context.Context, hash common.Hash) (*types.Block, error) {
226+
func (b *SimulatedBackend) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) {
227227
b.mu.Lock()
228228
defer b.mu.Unlock()
229229

@@ -250,7 +250,7 @@ func (b *SimulatedBackend) BlockByNumber(ctx context.Context, number *big.Int) (
250250

251251
// blockByNumberNoLock retrieves a block from the database by number, caching it
252252
// (associated with its hash) if found without Lock.
253-
func (b *SimulatedBackend) blockByNumberNoLock(_ context.Context, number *big.Int) (*types.Block, error) {
253+
func (b *SimulatedBackend) blockByNumberNoLock(ctx context.Context, number *big.Int) (*types.Block, error) {
254254
if number == nil || number.Cmp(b.pendingBlock.Number()) == 0 {
255255
return b.blockchain.CurrentBlock(), nil
256256
}
@@ -264,7 +264,7 @@ func (b *SimulatedBackend) blockByNumberNoLock(_ context.Context, number *big.In
264264
}
265265

266266
// HeaderByHash returns a block header from the current canonical chain.
267-
func (b *SimulatedBackend) HeaderByHash(_ context.Context, hash common.Hash) (*types.Header, error) {
267+
func (b *SimulatedBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
268268
b.mu.Lock()
269269
defer b.mu.Unlock()
270270

@@ -282,7 +282,7 @@ func (b *SimulatedBackend) HeaderByHash(_ context.Context, hash common.Hash) (*t
282282

283283
// HeaderByNumber returns a block header from the current canonical chain. If number is
284284
// nil, the latest known header is returned.
285-
func (b *SimulatedBackend) HeaderByNumber(_ context.Context, block *big.Int) (*types.Header, error) {
285+
func (b *SimulatedBackend) HeaderByNumber(ctx context.Context, block *big.Int) (*types.Header, error) {
286286
b.mu.Lock()
287287
defer b.mu.Unlock()
288288

@@ -294,7 +294,7 @@ func (b *SimulatedBackend) HeaderByNumber(_ context.Context, block *big.Int) (*t
294294
}
295295

296296
// TransactionCount returns the number of transactions in a given block.
297-
func (b *SimulatedBackend) TransactionCount(_ context.Context, blockHash common.Hash) (uint, error) {
297+
func (b *SimulatedBackend) TransactionCount(ctx context.Context, blockHash common.Hash) (uint, error) {
298298
b.mu.Lock()
299299
defer b.mu.Unlock()
300300

@@ -311,7 +311,7 @@ func (b *SimulatedBackend) TransactionCount(_ context.Context, blockHash common.
311311
}
312312

313313
// TransactionInBlock returns the transaction for a specific block at a specific index.
314-
func (b *SimulatedBackend) TransactionInBlock(_ context.Context, blockHash common.Hash, index uint) (*types.Transaction, error) {
314+
func (b *SimulatedBackend) TransactionInBlock(ctx context.Context, blockHash common.Hash, index uint) (*types.Transaction, error) {
315315
b.mu.Lock()
316316
defer b.mu.Unlock()
317317

@@ -338,7 +338,7 @@ func (b *SimulatedBackend) TransactionInBlock(_ context.Context, blockHash commo
338338
}
339339

340340
// PendingCodeAt returns the code associated with an account in the pending state.
341-
func (b *SimulatedBackend) PendingCodeAt(_ context.Context, contract common.Address) ([]byte, error) {
341+
func (b *SimulatedBackend) PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error) {
342342
b.mu.Lock()
343343
defer b.mu.Unlock()
344344

@@ -417,7 +417,7 @@ func (b *SimulatedBackend) PendingCallContract(ctx context.Context, call ethereu
417417

418418
// PendingNonceAt implements PendingStateReader.PendingNonceAt, retrieving
419419
// the nonce currently pending for the account.
420-
func (b *SimulatedBackend) PendingNonceAt(_ context.Context, account common.Address) (uint64, error) {
420+
func (b *SimulatedBackend) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) {
421421
b.mu.Lock()
422422
defer b.mu.Unlock()
423423

@@ -426,7 +426,7 @@ func (b *SimulatedBackend) PendingNonceAt(_ context.Context, account common.Addr
426426

427427
// SuggestGasPrice implements ContractTransactor.SuggestGasPrice. Since the simulated
428428
// chain doesn't have miners, we just return a gas price of 1 for any call.
429-
func (b *SimulatedBackend) SuggestGasPrice(_ context.Context) (*big.Int, error) {
429+
func (b *SimulatedBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
430430
return big.NewInt(1), nil
431431
}
432432

@@ -525,7 +525,7 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
525525

526526
// callContract implements common code between normal and pending contract calls.
527527
// state is modified during execution, make sure to copy it if necessary.
528-
func (b *SimulatedBackend) callContract(_ context.Context, call ethereum.CallMsg, block *types.Block, stateDB *state.StateDB) (*core.ExecutionResult, error) {
528+
func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallMsg, block *types.Block, stateDB *state.StateDB) (*core.ExecutionResult, error) {
529529
// Ensure message is initialized properly.
530530
if call.GasPrice == nil {
531531
call.GasPrice = big.NewInt(1)
@@ -553,7 +553,7 @@ func (b *SimulatedBackend) callContract(_ context.Context, call ethereum.CallMsg
553553

554554
// SendTransaction updates the pending block to include the given transaction.
555555
// It panics if the transaction is invalid.
556-
func (b *SimulatedBackend) SendTransaction(_ context.Context, tx *types.Transaction) error {
556+
func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error {
557557
b.mu.Lock()
558558
defer b.mu.Unlock()
559559

@@ -615,7 +615,7 @@ func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.Filter
615615

616616
// SubscribeFilterLogs creates a background log filtering operation, returning a
617617
// subscription immediately, which can be used to stream the found events.
618-
func (b *SimulatedBackend) SubscribeFilterLogs(_ context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) {
618+
func (b *SimulatedBackend) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) {
619619
// Subscribe to contract events
620620
sink := make(chan []*types.Log)
621621

@@ -648,7 +648,7 @@ func (b *SimulatedBackend) SubscribeFilterLogs(_ context.Context, query ethereum
648648
}
649649

650650
// SubscribeNewHead returns an event subscription for a new header.
651-
func (b *SimulatedBackend) SubscribeNewHead(_ context.Context, ch chan<- *types.Header) (ethereum.Subscription, error) {
651+
func (b *SimulatedBackend) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error) {
652652
// subscribe to a new head
653653
sink := make(chan *types.Header)
654654
sub := b.events.SubscribeNewHeads(sink)
@@ -724,26 +724,26 @@ type filterBackend struct {
724724
func (fb *filterBackend) ChainDb() ethdb.Database { return fb.db }
725725
func (fb *filterBackend) EventMux() *event.TypeMux { panic("not supported") }
726726

727-
func (fb *filterBackend) HeaderByNumber(_ context.Context, block rpc.BlockNumber) (*types.Header, error) {
727+
func (fb *filterBackend) HeaderByNumber(ctx context.Context, block rpc.BlockNumber) (*types.Header, error) {
728728
if block == rpc.LatestBlockNumber {
729729
return fb.bc.CurrentHeader(), nil
730730
}
731731
return fb.bc.GetHeaderByNumber(uint64(block.Int64())), nil
732732
}
733733

734-
func (fb *filterBackend) HeaderByHash(_ context.Context, hash common.Hash) (*types.Header, error) {
734+
func (fb *filterBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
735735
return fb.bc.GetHeaderByHash(hash), nil
736736
}
737737

738-
func (fb *filterBackend) GetReceipts(_ context.Context, hash common.Hash) (types.Receipts, error) {
738+
func (fb *filterBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {
739739
number := rawdb.ReadHeaderNumber(fb.db, hash)
740740
if number == nil {
741741
return nil, nil
742742
}
743743
return rawdb.ReadReceipts(fb.db, hash, *number, fb.bc.Config()), nil
744744
}
745745

746-
func (fb *filterBackend) GetLogs(_ context.Context, hash common.Hash) ([][]*types.Log, error) {
746+
func (fb *filterBackend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error) {
747747
number := rawdb.ReadHeaderNumber(fb.db, hash)
748748
if number == nil {
749749
return nil, nil
@@ -759,7 +759,7 @@ func (fb *filterBackend) GetLogs(_ context.Context, hash common.Hash) ([][]*type
759759
return logs, nil
760760
}
761761

762-
func (fb *filterBackend) SubscribeNewTxsEvent(_ chan<- core.NewTxsEvent) event.Subscription {
762+
func (fb *filterBackend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription {
763763
return nullSubscription()
764764
}
765765

@@ -775,13 +775,13 @@ func (fb *filterBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscr
775775
return fb.bc.SubscribeLogsEvent(ch)
776776
}
777777

778-
func (fb *filterBackend) SubscribePendingLogsEvent(_ chan<- []*types.Log) event.Subscription {
778+
func (fb *filterBackend) SubscribePendingLogsEvent(ch chan<- []*types.Log) event.Subscription {
779779
return nullSubscription()
780780
}
781781

782782
func (fb *filterBackend) BloomStatus() (uint64, uint64) { return 4096, 0 }
783783

784-
func (fb *filterBackend) ServiceFilter(_ context.Context, _ *bloombits.MatcherSession) {
784+
func (fb *filterBackend) ServiceFilter(ctx context.Context, ms *bloombits.MatcherSession) {
785785
panic("not supported")
786786
}
787787

accounts/abi/bind/backends/simulated_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,12 +1086,12 @@ func TestSimulatedBackend_CallContractRevert(t *testing.T) {
10861086
t.Errorf("result from %v was not nil: %v", key, res)
10871087
}
10881088
if val != nil {
1089-
rErr, ok := err.(*revertError)
1089+
rerr, ok := err.(*revertError)
10901090
if !ok {
10911091
t.Errorf("expect revert error")
10921092
}
1093-
if rErr.Error() != "execution reverted: "+val.(string) {
1094-
t.Errorf("error was malformed: got %v want %v", rErr.Error(), val)
1093+
if rerr.Error() != "execution reverted: "+val.(string) {
1094+
t.Errorf("error was malformed: got %v want %v", rerr.Error(), val)
10951095
}
10961096
} else {
10971097
// revert(0x0,0x0)

0 commit comments

Comments
 (0)