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
e536bb52
Unverified
Commit
e536bb52
authored
May 10, 2021
by
Felix Lange
Committed by
GitHub
May 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/protocols/snap: adapt to uint256 API changes (#22851)
parent
c0e201b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
range.go
eth/protocols/snap/range.go
+9
-8
No files found.
eth/protocols/snap/range.go
View file @
e536bb52
...
@@ -42,15 +42,15 @@ func newHashRange(start common.Hash, num uint64) *hashRange {
...
@@ -42,15 +42,15 @@ func newHashRange(start common.Hash, num uint64) *hashRange {
step256
.
SetFromBig
(
step
)
step256
.
SetFromBig
(
step
)
return
&
hashRange
{
return
&
hashRange
{
current
:
uint256
.
NewInt
(
)
.
SetBytes32
(
start
[
:
]),
current
:
new
(
uint256
.
Int
)
.
SetBytes32
(
start
[
:
]),
step
:
step256
,
step
:
step256
,
}
}
}
}
// Next pushes the hash range to the next interval.
// Next pushes the hash range to the next interval.
func
(
r
*
hashRange
)
Next
()
bool
{
func
(
r
*
hashRange
)
Next
()
bool
{
next
:=
new
(
uint256
.
Int
)
next
,
overflow
:=
new
(
uint256
.
Int
)
.
AddOverflow
(
r
.
current
,
r
.
step
)
if
overflow
:=
next
.
AddOverflow
(
r
.
current
,
r
.
step
);
overflow
{
if
overflow
{
return
false
return
false
}
}
r
.
current
=
next
r
.
current
=
next
...
@@ -65,16 +65,17 @@ func (r *hashRange) Start() common.Hash {
...
@@ -65,16 +65,17 @@ func (r *hashRange) Start() common.Hash {
// End returns the last hash in the current interval.
// End returns the last hash in the current interval.
func
(
r
*
hashRange
)
End
()
common
.
Hash
{
func
(
r
*
hashRange
)
End
()
common
.
Hash
{
// If the end overflows (non divisible range), return a shorter interval
// If the end overflows (non divisible range), return a shorter interval
next
:=
new
(
uint256
.
Int
)
next
,
overflow
:=
new
(
uint256
.
Int
)
.
AddOverflow
(
r
.
current
,
r
.
step
)
if
overflow
:=
next
.
AddOverflow
(
r
.
current
,
r
.
step
);
overflow
{
if
overflow
{
return
common
.
HexToHash
(
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
)
return
common
.
HexToHash
(
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
)
}
}
return
ne
w
(
uint256
.
Int
)
.
Sub
(
next
,
uint256
.
NewInt
()
.
SetOne
()
)
.
Bytes32
()
return
ne
xt
.
SubUint64
(
next
,
1
)
.
Bytes32
()
}
}
// incHash returns the next hash, in lexicographical order (a.k.a plus one)
// incHash returns the next hash, in lexicographical order (a.k.a plus one)
func
incHash
(
h
common
.
Hash
)
common
.
Hash
{
func
incHash
(
h
common
.
Hash
)
common
.
Hash
{
a
:=
uint256
.
NewInt
()
.
SetBytes32
(
h
[
:
])
var
a
uint256
.
Int
a
.
Add
(
a
,
uint256
.
NewInt
()
.
SetOne
())
a
.
SetBytes32
(
h
[
:
])
a
.
AddUint64
(
&
a
,
1
)
return
common
.
Hash
(
a
.
Bytes32
())
return
common
.
Hash
(
a
.
Bytes32
())
}
}
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