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
9b46986e
Unverified
Commit
9b46986e
authored
Aug 24, 2023
by
Felix Lange
Committed by
GitHub
Aug 24, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all: use rlp.DecodeBytes instead of rlp.Decode where possible (#27994)
parent
60ec41ce
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
13 additions
and
17 deletions
+13
-17
accessors_chain.go
core/rawdb/accessors_chain.go
+3
-3
accessors_sync.go
core/rawdb/accessors_sync.go
+1
-3
iterator.go
core/state/iterator.go
+1
-1
sync.go
core/state/sync.go
+1
-3
transaction_test.go
core/types/transaction_test.go
+1
-1
api.go
eth/tracers/api.go
+1
-2
odr_util.go
light/odr_util.go
+1
-2
v4wire.go
p2p/discover/v4wire/v4wire.go
+2
-0
api_test.go
signer/core/api_test.go
+2
-2
No files found.
core/rawdb/accessors_chain.go
View file @
9b46986e
...
...
@@ -381,7 +381,7 @@ func ReadHeader(db ethdb.Reader, hash common.Hash, number uint64) *types.Header
return
nil
}
header
:=
new
(
types
.
Header
)
if
err
:=
rlp
.
Decode
(
bytes
.
NewReader
(
data
)
,
header
);
err
!=
nil
{
if
err
:=
rlp
.
Decode
Bytes
(
data
,
header
);
err
!=
nil
{
log
.
Error
(
"Invalid block header RLP"
,
"hash"
,
hash
,
"err"
,
err
)
return
nil
}
...
...
@@ -498,7 +498,7 @@ func ReadBody(db ethdb.Reader, hash common.Hash, number uint64) *types.Body {
return
nil
}
body
:=
new
(
types
.
Body
)
if
err
:=
rlp
.
Decode
(
bytes
.
NewReader
(
data
)
,
body
);
err
!=
nil
{
if
err
:=
rlp
.
Decode
Bytes
(
data
,
body
);
err
!=
nil
{
log
.
Error
(
"Invalid block body RLP"
,
"hash"
,
hash
,
"err"
,
err
)
return
nil
}
...
...
@@ -544,7 +544,7 @@ func ReadTd(db ethdb.Reader, hash common.Hash, number uint64) *big.Int {
return
nil
}
td
:=
new
(
big
.
Int
)
if
err
:=
rlp
.
Decode
(
bytes
.
NewReader
(
data
)
,
td
);
err
!=
nil
{
if
err
:=
rlp
.
Decode
Bytes
(
data
,
td
);
err
!=
nil
{
log
.
Error
(
"Invalid block total difficulty RLP"
,
"hash"
,
hash
,
"err"
,
err
)
return
nil
}
...
...
core/rawdb/accessors_sync.go
View file @
9b46986e
...
...
@@ -17,8 +17,6 @@
package
rawdb
import
(
"bytes"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/log"
...
...
@@ -53,7 +51,7 @@ func ReadSkeletonHeader(db ethdb.KeyValueReader, number uint64) *types.Header {
return
nil
}
header
:=
new
(
types
.
Header
)
if
err
:=
rlp
.
Decode
(
bytes
.
NewReader
(
data
)
,
header
);
err
!=
nil
{
if
err
:=
rlp
.
Decode
Bytes
(
data
,
header
);
err
!=
nil
{
log
.
Error
(
"Invalid skeleton header RLP"
,
"number"
,
number
,
"err"
,
err
)
return
nil
}
...
...
core/state/iterator.go
View file @
9b46986e
...
...
@@ -112,7 +112,7 @@ func (it *nodeIterator) step() error {
}
// Otherwise we've reached an account node, initiate data iteration
var
account
types
.
StateAccount
if
err
:=
rlp
.
Decode
(
bytes
.
NewReader
(
it
.
stateIt
.
LeafBlob
()
),
&
account
);
err
!=
nil
{
if
err
:=
rlp
.
Decode
Bytes
(
it
.
stateIt
.
LeafBlob
(
),
&
account
);
err
!=
nil
{
return
err
}
// Lookup the preimage of account hash
...
...
core/state/sync.go
View file @
9b46986e
...
...
@@ -17,8 +17,6 @@
package
state
import
(
"bytes"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
...
...
@@ -45,7 +43,7 @@ func NewStateSync(root common.Hash, database ethdb.KeyValueReader, onLeaf func(k
}
}
var
obj
types
.
StateAccount
if
err
:=
rlp
.
Decode
(
bytes
.
NewReader
(
leaf
)
,
&
obj
);
err
!=
nil
{
if
err
:=
rlp
.
Decode
Bytes
(
leaf
,
&
obj
);
err
!=
nil
{
return
err
}
syncer
.
AddSubTrie
(
obj
.
Root
,
path
,
parent
,
parentPath
,
onSlot
)
...
...
core/types/transaction_test.go
View file @
9b46986e
...
...
@@ -214,7 +214,7 @@ func TestEIP2718TransactionEncode(t *testing.T) {
func
decodeTx
(
data
[]
byte
)
(
*
Transaction
,
error
)
{
var
tx
Transaction
t
,
err
:=
&
tx
,
rlp
.
Decode
(
bytes
.
NewReader
(
data
)
,
&
tx
)
t
,
err
:=
&
tx
,
rlp
.
Decode
Bytes
(
data
,
&
tx
)
return
t
,
err
}
...
...
eth/tracers/api.go
View file @
9b46986e
...
...
@@ -18,7 +18,6 @@ package tracers
import
(
"bufio"
"bytes"
"context"
"encoding/json"
"errors"
...
...
@@ -453,7 +452,7 @@ func (api *API) TraceBlockByHash(ctx context.Context, hash common.Hash, config *
// and returns them as a JSON object.
func
(
api
*
API
)
TraceBlock
(
ctx
context
.
Context
,
blob
hexutil
.
Bytes
,
config
*
TraceConfig
)
([]
*
txTraceResult
,
error
)
{
block
:=
new
(
types
.
Block
)
if
err
:=
rlp
.
Decode
(
bytes
.
NewReader
(
blob
)
,
block
);
err
!=
nil
{
if
err
:=
rlp
.
Decode
Bytes
(
blob
,
block
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"could not decode block: %v"
,
err
)
}
return
api
.
traceBlock
(
ctx
,
block
,
config
)
...
...
light/odr_util.go
View file @
9b46986e
...
...
@@ -17,7 +17,6 @@
package
light
import
(
"bytes"
"context"
"errors"
"math/big"
...
...
@@ -126,7 +125,7 @@ func GetBody(ctx context.Context, odr OdrBackend, hash common.Hash, number uint6
return
nil
,
err
}
body
:=
new
(
types
.
Body
)
if
err
:=
rlp
.
Decode
(
bytes
.
NewReader
(
data
)
,
body
);
err
!=
nil
{
if
err
:=
rlp
.
Decode
Bytes
(
data
,
body
);
err
!=
nil
{
return
nil
,
err
}
return
body
,
nil
...
...
p2p/discover/v4wire/v4wire.go
View file @
9b46986e
...
...
@@ -238,6 +238,8 @@ func Decode(input []byte) (Packet, Pubkey, []byte, error) {
default
:
return
nil
,
fromKey
,
hash
,
fmt
.
Errorf
(
"unknown type: %d"
,
ptype
)
}
// Here we use NewStream to allow for additional data after the first
// RLP object (forward-compatibility).
s
:=
rlp
.
NewStream
(
bytes
.
NewReader
(
sigdata
[
1
:
]),
0
)
err
=
s
.
Decode
(
req
)
return
req
,
fromKey
,
hash
,
err
...
...
signer/core/api_test.go
View file @
9b46986e
...
...
@@ -282,7 +282,7 @@ func TestSignTx(t *testing.T) {
t
.
Fatal
(
err
)
}
parsedTx
:=
&
types
.
Transaction
{}
rlp
.
Decode
(
bytes
.
NewReader
(
res
.
Raw
)
,
parsedTx
)
rlp
.
Decode
Bytes
(
res
.
Raw
,
parsedTx
)
//The tx should NOT be modified by the UI
if
parsedTx
.
Value
()
.
Cmp
(
tx
.
Value
.
ToInt
())
!=
0
{
...
...
@@ -308,7 +308,7 @@ func TestSignTx(t *testing.T) {
t
.
Fatal
(
err
)
}
parsedTx2
:=
&
types
.
Transaction
{}
rlp
.
Decode
(
bytes
.
NewReader
(
res
.
Raw
)
,
parsedTx2
)
rlp
.
Decode
Bytes
(
res
.
Raw
,
parsedTx2
)
//The tx should be modified by the UI
if
parsedTx2
.
Value
()
.
Cmp
(
tx
.
Value
.
ToInt
())
!=
0
{
...
...
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