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
b6d4f6b6
Commit
b6d4f6b6
authored
Nov 21, 2019
by
Felix Lange
Committed by
Péter Szilágyi
Nov 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/types: remove BlockBy sorting code (#20355)
parent
0ec5ab41
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
26 deletions
+4
-26
blockchain.go
core/blockchain.go
+4
-2
block.go
core/types/block.go
+0
-24
No files found.
core/blockchain.go
View file @
b6d4f6b6
...
...
@@ -23,6 +23,7 @@ import (
"io"
"math/big"
mrand
"math/rand"
"sort"
"sync"
"sync/atomic"
"time"
...
...
@@ -855,8 +856,9 @@ func (bc *BlockChain) procFutureBlocks() {
}
}
if
len
(
blocks
)
>
0
{
types
.
BlockBy
(
types
.
Number
)
.
Sort
(
blocks
)
sort
.
Slice
(
blocks
,
func
(
i
,
j
int
)
bool
{
return
blocks
[
i
]
.
NumberU64
()
<
blocks
[
j
]
.
NumberU64
()
})
// Insert one by one as chain insertion needs contiguous ancestry between blocks
for
i
:=
range
blocks
{
bc
.
InsertChain
(
blocks
[
i
:
i
+
1
])
...
...
core/types/block.go
View file @
b6d4f6b6
...
...
@@ -23,7 +23,6 @@ import (
"io"
"math/big"
"reflect"
"sort"
"sync/atomic"
"time"
...
...
@@ -394,26 +393,3 @@ func (b *Block) Hash() common.Hash {
}
type
Blocks
[]
*
Block
type
BlockBy
func
(
b1
,
b2
*
Block
)
bool
func
(
self
BlockBy
)
Sort
(
blocks
Blocks
)
{
bs
:=
blockSorter
{
blocks
:
blocks
,
by
:
self
,
}
sort
.
Sort
(
bs
)
}
type
blockSorter
struct
{
blocks
Blocks
by
func
(
b1
,
b2
*
Block
)
bool
}
func
(
self
blockSorter
)
Len
()
int
{
return
len
(
self
.
blocks
)
}
func
(
self
blockSorter
)
Swap
(
i
,
j
int
)
{
self
.
blocks
[
i
],
self
.
blocks
[
j
]
=
self
.
blocks
[
j
],
self
.
blocks
[
i
]
}
func
(
self
blockSorter
)
Less
(
i
,
j
int
)
bool
{
return
self
.
by
(
self
.
blocks
[
i
],
self
.
blocks
[
j
])
}
func
Number
(
b1
,
b2
*
Block
)
bool
{
return
b1
.
header
.
Number
.
Cmp
(
b2
.
header
.
Number
)
<
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