mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-21 06:04:33 +00:00
accounts/abi: mutex lock in TransactionByHash and code cleanup (#19133)
This commit is contained in:
parent
dcc3fc3ec3
commit
5d0dea852e
1 changed files with 5 additions and 4 deletions
|
|
@ -269,17 +269,18 @@ func (b *SimulatedBackend) TransactionReceipt(ctx context.Context, txHash common
|
|||
// blockchain. The isPending return value indicates whether the transaction has been
|
||||
// mined yet. Note that the transaction may not be part of the canonical chain even if
|
||||
// it's not pending.
|
||||
func (b *SimulatedBackend) TransactionByHash(ctx context.Context, txHash common.Hash) (tx *types.Transaction, isPending bool, err error) {
|
||||
tx = b.pendingBlock.Transaction(txHash)
|
||||
func (b *SimulatedBackend) TransactionByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error) {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
|
||||
tx := b.pendingBlock.Transaction(txHash)
|
||||
if tx != nil {
|
||||
return tx, true, nil
|
||||
}
|
||||
|
||||
tx, _, _, _ = rawdb.ReadTransaction(b.database, txHash)
|
||||
if tx != nil {
|
||||
return tx, false, nil
|
||||
}
|
||||
|
||||
return nil, false, ethereum.ErrNotFound
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue