good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
c036fe35
Unverified
Commit
c036fe35
authored
Apr 21, 2020
by
Martin Holst Swende
Browse files
Options
Downloads
Patches
Plain Diff
core/state/snapshot: make difflayer account iterator seek operation inclusive
parent
7599999d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/state/snapshot/iterator.go
+1
-1
1 addition, 1 deletion
core/state/snapshot/iterator.go
core/state/snapshot/iterator_test.go
+17
-4
17 additions, 4 deletions
core/state/snapshot/iterator_test.go
with
18 additions
and
5 deletions
core/state/snapshot/iterator.go
+
1
−
1
View file @
c036fe35
...
...
@@ -70,7 +70,7 @@ func (dl *diffLayer) AccountIterator(seek common.Hash) AccountIterator {
// Seek out the requested starting account
hashes
:=
dl
.
AccountList
()
index
:=
sort
.
Search
(
len
(
hashes
),
func
(
i
int
)
bool
{
return
bytes
.
Compare
(
seek
[
:
],
hashes
[
i
][
:
])
<
0
return
bytes
.
Compare
(
seek
[
:
],
hashes
[
i
][
:
])
<
=
0
})
// Assemble and returned the already seeked iterator
return
&
diffAccountIterator
{
...
...
This diff is collapsed.
Click to expand it.
core/state/snapshot/iterator_test.go
+
17
−
4
View file @
c036fe35
...
...
@@ -351,22 +351,30 @@ func TestAccountIteratorSeek(t *testing.T) {
snaps
.
Update
(
common
.
HexToHash
(
"0x04"
),
common
.
HexToHash
(
"0x03"
),
nil
,
randomAccountSet
(
"0xcc"
,
"0xf0"
,
"0xff"
),
nil
)
// Construct various iterators and ensure their tranversal is correct
// Account set is now
// 02: aa, ee, f0, ff
// 03: aa, bb, dd, ee, f0 (, f0), ff
// 04: aa, bb, cc, dd, ee, f0 (, f0), ff (, ff)
// Construct various iterators and ensure their traversal is correct
it
,
_
:=
snaps
.
AccountIterator
(
common
.
HexToHash
(
"0x02"
),
common
.
HexToHash
(
"0xdd"
))
defer
it
.
Release
()
verifyIterator
(
t
,
3
,
it
)
// expected: ee, f0, ff
it
,
_
=
snaps
.
AccountIterator
(
common
.
HexToHash
(
"0x02"
),
common
.
HexToHash
(
"0xaa"
))
defer
it
.
Release
()
verifyIterator
(
t
,
3
,
it
)
// expected: ee, f0, ff
verifyIterator
(
t
,
4
,
it
)
// expected:
aa,
ee, f0, ff
it
,
_
=
snaps
.
AccountIterator
(
common
.
HexToHash
(
"0x02"
),
common
.
HexToHash
(
"0xff"
))
defer
it
.
Release
()
verifyIterator
(
t
,
1
,
it
)
// expected: ff
it
,
_
=
snaps
.
AccountIterator
(
common
.
HexToHash
(
"0x02"
),
common
.
HexToHash
(
"0xff1"
))
defer
it
.
Release
()
verifyIterator
(
t
,
0
,
it
)
// expected: nothing
it
,
_
=
snaps
.
AccountIterator
(
common
.
HexToHash
(
"0x04"
),
common
.
HexToHash
(
"0xbb"
))
defer
it
.
Release
()
verifyIterator
(
t
,
5
,
it
)
// expected: cc, dd, ee, f0, ff
verifyIterator
(
t
,
6
,
it
)
// expected:
bb,
cc, dd, ee, f0, ff
it
,
_
=
snaps
.
AccountIterator
(
common
.
HexToHash
(
"0x04"
),
common
.
HexToHash
(
"0xef"
))
defer
it
.
Release
()
...
...
@@ -374,11 +382,16 @@ func TestAccountIteratorSeek(t *testing.T) {
it
,
_
=
snaps
.
AccountIterator
(
common
.
HexToHash
(
"0x04"
),
common
.
HexToHash
(
"0xf0"
))
defer
it
.
Release
()
verifyIterator
(
t
,
1
,
it
)
// expected: ff
verifyIterator
(
t
,
2
,
it
)
// expected:
f0,
ff
it
,
_
=
snaps
.
AccountIterator
(
common
.
HexToHash
(
"0x04"
),
common
.
HexToHash
(
"0xff"
))
defer
it
.
Release
()
verifyIterator
(
t
,
1
,
it
)
// expected: ff
it
,
_
=
snaps
.
AccountIterator
(
common
.
HexToHash
(
"0x04"
),
common
.
HexToHash
(
"0xff1"
))
defer
it
.
Release
()
verifyIterator
(
t
,
0
,
it
)
// expected: nothing
}
// TestIteratorDeletions tests that the iterator behaves correct when there are
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment