Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
f80ce141
Unverified
Commit
f80ce141
authored
Jan 18, 2022
by
Pantelis Peslis
Committed by
GitHub
Jan 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounts/abi/bind/backends: return errors instead of panic (#24242)
parent
b1f09596
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
4 deletions
+3
-4
simulated.go
accounts/abi/bind/backends/simulated.go
+3
-4
No files found.
accounts/abi/bind/backends/simulated.go
View file @
f80ce141
...
...
@@ -639,7 +639,6 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM
}
// SendTransaction updates the pending block to include the given transaction.
// It panics if the transaction is invalid.
func
(
b
*
SimulatedBackend
)
SendTransaction
(
ctx
context
.
Context
,
tx
*
types
.
Transaction
)
error
{
b
.
mu
.
Lock
()
defer
b
.
mu
.
Unlock
()
...
...
@@ -647,17 +646,17 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
// Get the last block
block
,
err
:=
b
.
blockByHash
(
ctx
,
b
.
pendingBlock
.
ParentHash
())
if
err
!=
nil
{
panic
(
"could not fetch parent"
)
return
fmt
.
Errorf
(
"could not fetch parent"
)
}
// Check transaction validity
signer
:=
types
.
MakeSigner
(
b
.
blockchain
.
Config
(),
block
.
Number
())
sender
,
err
:=
types
.
Sender
(
signer
,
tx
)
if
err
!=
nil
{
panic
(
fmt
.
Errorf
(
"invalid transaction: %v"
,
err
)
)
return
fmt
.
Errorf
(
"invalid transaction: %v"
,
err
)
}
nonce
:=
b
.
pendingState
.
GetNonce
(
sender
)
if
tx
.
Nonce
()
!=
nonce
{
panic
(
fmt
.
Errorf
(
"invalid transaction nonce: got %d, want %d"
,
tx
.
Nonce
(),
nonce
)
)
return
fmt
.
Errorf
(
"invalid transaction nonce: got %d, want %d"
,
tx
.
Nonce
(),
nonce
)
}
// Include tx in chain
blocks
,
_
:=
core
.
GenerateChain
(
b
.
config
,
block
,
ethash
.
NewFaker
(),
b
.
database
,
1
,
func
(
number
int
,
block
*
core
.
BlockGen
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment