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
b0095eeb
Unverified
Commit
b0095eeb
authored
May 24, 2023
by
Delweng
Committed by
GitHub
May 24, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ethclient,event: replace noarg fmt.Errorf with errors.New (#27334)
Signed-off-by:
jsvisa
<
delweng@gmail.com
>
parent
e9c3183c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
10 deletions
+10
-10
ethclient.go
ethclient/ethclient.go
+7
-7
ethclient_test.go
ethclient/ethclient_test.go
+1
-2
feed_test.go
event/feed_test.go
+2
-1
No files found.
ethclient/ethclient.go
View file @
b0095eeb
...
@@ -138,16 +138,16 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface
...
@@ -138,16 +138,16 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface
}
}
// Quick-verify transaction and uncle lists. This mostly helps with debugging the server.
// Quick-verify transaction and uncle lists. This mostly helps with debugging the server.
if
head
.
UncleHash
==
types
.
EmptyUncleHash
&&
len
(
body
.
UncleHashes
)
>
0
{
if
head
.
UncleHash
==
types
.
EmptyUncleHash
&&
len
(
body
.
UncleHashes
)
>
0
{
return
nil
,
fmt
.
Errorf
(
"server returned non-empty uncle list but block header indicates no uncles"
)
return
nil
,
errors
.
New
(
"server returned non-empty uncle list but block header indicates no uncles"
)
}
}
if
head
.
UncleHash
!=
types
.
EmptyUncleHash
&&
len
(
body
.
UncleHashes
)
==
0
{
if
head
.
UncleHash
!=
types
.
EmptyUncleHash
&&
len
(
body
.
UncleHashes
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"server returned empty uncle list but block header indicates uncles"
)
return
nil
,
errors
.
New
(
"server returned empty uncle list but block header indicates uncles"
)
}
}
if
head
.
TxHash
==
types
.
EmptyTxsHash
&&
len
(
body
.
Transactions
)
>
0
{
if
head
.
TxHash
==
types
.
EmptyTxsHash
&&
len
(
body
.
Transactions
)
>
0
{
return
nil
,
fmt
.
Errorf
(
"server returned non-empty transaction list but block header indicates no transactions"
)
return
nil
,
errors
.
New
(
"server returned non-empty transaction list but block header indicates no transactions"
)
}
}
if
head
.
TxHash
!=
types
.
EmptyTxsHash
&&
len
(
body
.
Transactions
)
==
0
{
if
head
.
TxHash
!=
types
.
EmptyTxsHash
&&
len
(
body
.
Transactions
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"server returned empty transaction list but block header indicates transactions"
)
return
nil
,
errors
.
New
(
"server returned empty transaction list but block header indicates transactions"
)
}
}
// Load uncles because they are not included in the block response.
// Load uncles because they are not included in the block response.
var
uncles
[]
*
types
.
Header
var
uncles
[]
*
types
.
Header
...
@@ -232,7 +232,7 @@ func (ec *Client) TransactionByHash(ctx context.Context, hash common.Hash) (tx *
...
@@ -232,7 +232,7 @@ func (ec *Client) TransactionByHash(ctx context.Context, hash common.Hash) (tx *
}
else
if
json
==
nil
{
}
else
if
json
==
nil
{
return
nil
,
false
,
ethereum
.
NotFound
return
nil
,
false
,
ethereum
.
NotFound
}
else
if
_
,
r
,
_
:=
json
.
tx
.
RawSignatureValues
();
r
==
nil
{
}
else
if
_
,
r
,
_
:=
json
.
tx
.
RawSignatureValues
();
r
==
nil
{
return
nil
,
false
,
fmt
.
Errorf
(
"server returned transaction without signature"
)
return
nil
,
false
,
errors
.
New
(
"server returned transaction without signature"
)
}
}
if
json
.
From
!=
nil
&&
json
.
BlockHash
!=
nil
{
if
json
.
From
!=
nil
&&
json
.
BlockHash
!=
nil
{
setSenderFromServer
(
json
.
tx
,
*
json
.
From
,
*
json
.
BlockHash
)
setSenderFromServer
(
json
.
tx
,
*
json
.
From
,
*
json
.
BlockHash
)
...
@@ -284,7 +284,7 @@ func (ec *Client) TransactionInBlock(ctx context.Context, blockHash common.Hash,
...
@@ -284,7 +284,7 @@ func (ec *Client) TransactionInBlock(ctx context.Context, blockHash common.Hash,
if
json
==
nil
{
if
json
==
nil
{
return
nil
,
ethereum
.
NotFound
return
nil
,
ethereum
.
NotFound
}
else
if
_
,
r
,
_
:=
json
.
tx
.
RawSignatureValues
();
r
==
nil
{
}
else
if
_
,
r
,
_
:=
json
.
tx
.
RawSignatureValues
();
r
==
nil
{
return
nil
,
fmt
.
Errorf
(
"server returned transaction without signature"
)
return
nil
,
errors
.
New
(
"server returned transaction without signature"
)
}
}
if
json
.
From
!=
nil
&&
json
.
BlockHash
!=
nil
{
if
json
.
From
!=
nil
&&
json
.
BlockHash
!=
nil
{
setSenderFromServer
(
json
.
tx
,
*
json
.
From
,
*
json
.
BlockHash
)
setSenderFromServer
(
json
.
tx
,
*
json
.
From
,
*
json
.
BlockHash
)
...
@@ -421,7 +421,7 @@ func toFilterArg(q ethereum.FilterQuery) (interface{}, error) {
...
@@ -421,7 +421,7 @@ func toFilterArg(q ethereum.FilterQuery) (interface{}, error) {
if
q
.
BlockHash
!=
nil
{
if
q
.
BlockHash
!=
nil
{
arg
[
"blockHash"
]
=
*
q
.
BlockHash
arg
[
"blockHash"
]
=
*
q
.
BlockHash
if
q
.
FromBlock
!=
nil
||
q
.
ToBlock
!=
nil
{
if
q
.
FromBlock
!=
nil
||
q
.
ToBlock
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"cannot specify both BlockHash and FromBlock/ToBlock"
)
return
nil
,
errors
.
New
(
"cannot specify both BlockHash and FromBlock/ToBlock"
)
}
}
}
else
{
}
else
{
if
q
.
FromBlock
==
nil
{
if
q
.
FromBlock
==
nil
{
...
...
ethclient/ethclient_test.go
View file @
b0095eeb
...
@@ -20,7 +20,6 @@ import (
...
@@ -20,7 +20,6 @@ import (
"bytes"
"bytes"
"context"
"context"
"errors"
"errors"
"fmt"
"math/big"
"math/big"
"reflect"
"reflect"
"testing"
"testing"
...
@@ -55,7 +54,7 @@ var (
...
@@ -55,7 +54,7 @@ var (
)
)
func
TestToFilterArg
(
t
*
testing
.
T
)
{
func
TestToFilterArg
(
t
*
testing
.
T
)
{
blockHashErr
:=
fmt
.
Errorf
(
"cannot specify both BlockHash and FromBlock/ToBlock"
)
blockHashErr
:=
errors
.
New
(
"cannot specify both BlockHash and FromBlock/ToBlock"
)
addresses
:=
[]
common
.
Address
{
addresses
:=
[]
common
.
Address
{
common
.
HexToAddress
(
"0xD36722ADeC3EdCB29c8e7b5a47f352D701393462"
),
common
.
HexToAddress
(
"0xD36722ADeC3EdCB29c8e7b5a47f352D701393462"
),
}
}
...
...
event/feed_test.go
View file @
b0095eeb
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
event
package
event
import
(
import
(
"errors"
"fmt"
"fmt"
"reflect"
"reflect"
"sync"
"sync"
...
@@ -68,7 +69,7 @@ func checkPanic(want error, fn func()) (err error) {
...
@@ -68,7 +69,7 @@ func checkPanic(want error, fn func()) (err error) {
defer
func
()
{
defer
func
()
{
panic
:=
recover
()
panic
:=
recover
()
if
panic
==
nil
{
if
panic
==
nil
{
err
=
fmt
.
Errorf
(
"didn't panic"
)
err
=
errors
.
New
(
"didn't panic"
)
}
else
if
!
reflect
.
DeepEqual
(
panic
,
want
)
{
}
else
if
!
reflect
.
DeepEqual
(
panic
,
want
)
{
err
=
fmt
.
Errorf
(
"panicked with wrong error: got %q, want %q"
,
panic
,
want
)
err
=
fmt
.
Errorf
(
"panicked with wrong error: got %q, want %q"
,
panic
,
want
)
}
}
...
...
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