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
0275fcb3
Commit
0275fcb3
authored
May 29, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/downloader: clean up and simplify the code a bit
parent
abdfcda4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
13 deletions
+3
-13
downloader.go
eth/downloader/downloader.go
+3
-13
No files found.
eth/downloader/downloader.go
View file @
0275fcb3
...
...
@@ -3,20 +3,18 @@ package downloader
import
(
"bytes"
"errors"
"fmt"
"math/rand"
"sync"
"sync/atomic"
"time"
"gopkg.in/fatih/set.v0"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"gopkg.in/fatih/set.v0"
)
const
(
...
...
@@ -301,7 +299,6 @@ func (d *Downloader) fetchHashes(p *peer, h common.Hash) error {
d
.
queue
.
Insert
(
hashPack
.
hashes
[
:
index
+
1
])
if
err
:=
d
.
banBlocks
(
active
.
id
,
hash
);
err
!=
nil
{
fmt
.
Println
(
"ban err"
,
err
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Failed to ban batch of blocks: %v"
,
err
)
}
return
ErrInvalidChain
...
...
@@ -596,15 +593,8 @@ func (d *Downloader) banBlocks(peerId string, head common.Hash) error {
if
len
(
blocks
)
==
0
{
return
errors
.
New
(
"no blocks returned to ban"
)
}
// Got the batch of invalid blocks, reconstruct their chain order
for
i
:=
0
;
i
<
len
(
blocks
);
i
++
{
for
j
:=
i
+
1
;
j
<
len
(
blocks
);
j
++
{
if
blocks
[
i
]
.
NumberU64
()
>
blocks
[
j
]
.
NumberU64
()
{
blocks
[
i
],
blocks
[
j
]
=
blocks
[
j
],
blocks
[
i
]
}
}
}
// Ensure we're really banning the correct blocks
// Reconstruct the original chain order and ensure we're banning the correct blocks
types
.
BlockBy
(
types
.
Number
)
.
Sort
(
blocks
)
if
bytes
.
Compare
(
blocks
[
0
]
.
Hash
()
.
Bytes
(),
head
.
Bytes
())
!=
0
{
return
errors
.
New
(
"head block not the banned one"
)
}
...
...
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