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
99eb0b52
Unverified
Commit
99eb0b52
authored
Jun 07, 2023
by
Stephen Guo
Committed by
GitHub
Jun 07, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rlp: use identical receiver names for encBuffer methods (#27430)
parent
fbe432fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
encbuffer.go
rlp/encbuffer.go
+16
-16
No files found.
rlp/encbuffer.go
View file @
99eb0b52
...
...
@@ -56,18 +56,18 @@ func (buf *encBuffer) size() int {
}
// makeBytes creates the encoder output.
func
(
w
*
encBuffer
)
makeBytes
()
[]
byte
{
out
:=
make
([]
byte
,
w
.
size
())
w
.
copyTo
(
out
)
func
(
buf
*
encBuffer
)
makeBytes
()
[]
byte
{
out
:=
make
([]
byte
,
buf
.
size
())
buf
.
copyTo
(
out
)
return
out
}
func
(
w
*
encBuffer
)
copyTo
(
dst
[]
byte
)
{
func
(
buf
*
encBuffer
)
copyTo
(
dst
[]
byte
)
{
strpos
:=
0
pos
:=
0
for
_
,
head
:=
range
w
.
lheads
{
for
_
,
head
:=
range
buf
.
lheads
{
// write string data before header
n
:=
copy
(
dst
[
pos
:
],
w
.
str
[
strpos
:
head
.
offset
])
n
:=
copy
(
dst
[
pos
:
],
buf
.
str
[
strpos
:
head
.
offset
])
pos
+=
n
strpos
+=
n
// write the header
...
...
@@ -75,7 +75,7 @@ func (w *encBuffer) copyTo(dst []byte) {
pos
+=
len
(
enc
)
}
// copy string data after the last list header
copy
(
dst
[
pos
:
],
w
.
str
[
strpos
:
])
copy
(
dst
[
pos
:
],
buf
.
str
[
strpos
:
])
}
// writeTo writes the encoder output to w.
...
...
@@ -149,34 +149,34 @@ func (buf *encBuffer) writeString(s string) {
const
wordBytes
=
(
32
<<
(
uint64
(
^
big
.
Word
(
0
))
>>
63
))
/
8
// writeBigInt writes i as an integer.
func
(
w
*
encBuffer
)
writeBigInt
(
i
*
big
.
Int
)
{
func
(
buf
*
encBuffer
)
writeBigInt
(
i
*
big
.
Int
)
{
bitlen
:=
i
.
BitLen
()
if
bitlen
<=
64
{
w
.
writeUint64
(
i
.
Uint64
())
buf
.
writeUint64
(
i
.
Uint64
())
return
}
// Integer is larger than 64 bits, encode from i.Bits().
// The minimal byte length is bitlen rounded up to the next
// multiple of 8, divided by 8.
length
:=
((
bitlen
+
7
)
&
-
8
)
>>
3
w
.
encodeStringHeader
(
length
)
w
.
str
=
append
(
w
.
str
,
make
([]
byte
,
length
)
...
)
buf
.
encodeStringHeader
(
length
)
buf
.
str
=
append
(
buf
.
str
,
make
([]
byte
,
length
)
...
)
index
:=
length
b
uf
:=
w
.
str
[
len
(
w
.
str
)
-
length
:
]
b
ytesBuf
:=
buf
.
str
[
len
(
buf
.
str
)
-
length
:
]
for
_
,
d
:=
range
i
.
Bits
()
{
for
j
:=
0
;
j
<
wordBytes
&&
index
>
0
;
j
++
{
index
--
buf
[
index
]
=
byte
(
d
)
b
ytesB
uf
[
index
]
=
byte
(
d
)
d
>>=
8
}
}
}
// writeUint256 writes z as an integer.
func
(
w
*
encBuffer
)
writeUint256
(
z
*
uint256
.
Int
)
{
func
(
buf
*
encBuffer
)
writeUint256
(
z
*
uint256
.
Int
)
{
bitlen
:=
z
.
BitLen
()
if
bitlen
<=
64
{
w
.
writeUint64
(
z
.
Uint64
())
buf
.
writeUint64
(
z
.
Uint64
())
return
}
nBytes
:=
byte
((
bitlen
+
7
)
/
8
)
...
...
@@ -186,7 +186,7 @@ func (w *encBuffer) writeUint256(z *uint256.Int) {
binary
.
BigEndian
.
PutUint64
(
b
[
17
:
25
],
z
[
1
])
binary
.
BigEndian
.
PutUint64
(
b
[
25
:
33
],
z
[
0
])
b
[
32
-
nBytes
]
=
0x80
+
nBytes
w
.
str
=
append
(
w
.
str
,
b
[
32
-
nBytes
:
]
...
)
buf
.
str
=
append
(
buf
.
str
,
b
[
32
-
nBytes
:
]
...
)
}
// list adds a new list header to the header stack. It returns the index of the header.
...
...
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