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
b6d4f6b6
Commit
b6d4f6b6
authored
Nov 21, 2019
by
Felix Lange
Committed by
Péter Szilágyi
Nov 21, 2019
Browse files
Options
Downloads
Patches
Plain Diff
core/types: remove BlockBy sorting code (#20355)
parent
0ec5ab41
No related branches found
No related tags found
Loading
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/blockchain.go
+4
-2
4 additions, 2 deletions
core/blockchain.go
core/types/block.go
+0
-24
0 additions, 24 deletions
core/types/block.go
with
4 additions
and
26 deletions
core/blockchain.go
+
4
−
2
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
])
...
...
This diff is collapsed.
Click to expand it.
core/types/block.go
+
0
−
24
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
}
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