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
06a04158
Commit
06a04158
authored
May 21, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth, eth/downloader: remove duplicate consts, bump hash fetch to 2K
parent
52db6d8b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
13 deletions
+14
-13
downloader.go
eth/downloader/downloader.go
+6
-4
downloader_test.go
eth/downloader/downloader_test.go
+1
-1
queue.go
eth/downloader/queue.go
+1
-1
handler.go
eth/handler.go
+3
-3
peer.go
eth/peer.go
+3
-2
protocol.go
eth/protocol.go
+0
-2
No files found.
eth/downloader/downloader.go
View file @
06a04158
...
@@ -15,8 +15,10 @@ import (
...
@@ -15,8 +15,10 @@ import (
)
)
const
(
const
(
maxHashFetch
=
512
// Amount of hashes to be fetched per chunk
MinHashFetch
=
512
// Minimum amount of hashes to not consider a peer stalling
maxBlockFetch
=
128
// Amount of blocks to be fetched per chunk
MaxHashFetch
=
2048
// Amount of hashes to be fetched per retrieval request
MaxBlockFetch
=
128
// Amount of blocks to be fetched per retrieval request
peerCountTimeout
=
12
*
time
.
Second
// Amount of time it takes for the peer handler to ignore minDesiredPeerCount
peerCountTimeout
=
12
*
time
.
Second
// Amount of time it takes for the peer handler to ignore minDesiredPeerCount
hashTTL
=
5
*
time
.
Second
// Time it takes for a hash request to time out
hashTTL
=
5
*
time
.
Second
// Time it takes for a hash request to time out
)
)
...
@@ -290,7 +292,7 @@ func (d *Downloader) fetchHashes(p *peer, h common.Hash) error {
...
@@ -290,7 +292,7 @@ func (d *Downloader) fetchHashes(p *peer, h common.Hash) error {
}
}
if
!
done
{
if
!
done
{
// Check that the peer is not stalling the sync
// Check that the peer is not stalling the sync
if
len
(
inserts
)
<
max
HashFetch
{
if
len
(
inserts
)
<
Min
HashFetch
{
return
ErrStallingPeer
return
ErrStallingPeer
}
}
// Try and fetch a random block to verify the hash batch
// Try and fetch a random block to verify the hash batch
...
@@ -451,7 +453,7 @@ out:
...
@@ -451,7 +453,7 @@ out:
}
}
// Get a possible chunk. If nil is returned no chunk
// Get a possible chunk. If nil is returned no chunk
// could be returned due to no hashes available.
// could be returned due to no hashes available.
request
:=
d
.
queue
.
Reserve
(
peer
,
m
axBlockFetch
)
request
:=
d
.
queue
.
Reserve
(
peer
,
M
axBlockFetch
)
if
request
==
nil
{
if
request
==
nil
{
continue
continue
}
}
...
...
eth/downloader/downloader_test.go
View file @
06a04158
...
@@ -135,7 +135,7 @@ func (dl *downloadTester) getBlock(hash common.Hash) *types.Block {
...
@@ -135,7 +135,7 @@ func (dl *downloadTester) getBlock(hash common.Hash) *types.Block {
// getHashes retrieves a batch of hashes for reconstructing the chain.
// getHashes retrieves a batch of hashes for reconstructing the chain.
func
(
dl
*
downloadTester
)
getHashes
(
head
common
.
Hash
)
error
{
func
(
dl
*
downloadTester
)
getHashes
(
head
common
.
Hash
)
error
{
limit
:=
m
axHashFetch
limit
:=
M
axHashFetch
if
dl
.
maxHashFetch
>
0
{
if
dl
.
maxHashFetch
>
0
{
limit
=
dl
.
maxHashFetch
limit
=
dl
.
maxHashFetch
}
}
...
...
eth/downloader/queue.go
View file @
06a04158
...
@@ -17,7 +17,7 @@ import (
...
@@ -17,7 +17,7 @@ import (
)
)
const
(
const
(
blockCacheLimit
=
1024
// Maximum number of blocks to cache before throttling the download
blockCacheLimit
=
8
*
MaxBlockFetch
// Maximum number of blocks to cache before throttling the download
)
)
// fetchRequest is a currently running block retrieval operation.
// fetchRequest is a currently running block retrieval operation.
...
...
eth/handler.go
View file @
06a04158
...
@@ -206,8 +206,8 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
...
@@ -206,8 +206,8 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
return
errResp
(
ErrDecode
,
"->msg %v: %v"
,
msg
,
err
)
return
errResp
(
ErrDecode
,
"->msg %v: %v"
,
msg
,
err
)
}
}
if
request
.
Amount
>
maxHashes
{
if
request
.
Amount
>
downloader
.
MaxHashFetch
{
request
.
Amount
=
maxHashes
request
.
Amount
=
downloader
.
MaxHashFetch
}
}
hashes
:=
self
.
chainman
.
GetBlockHashesFromHash
(
request
.
Hash
,
request
.
Amount
)
hashes
:=
self
.
chainman
.
GetBlockHashesFromHash
(
request
.
Hash
,
request
.
Amount
)
...
@@ -254,7 +254,7 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
...
@@ -254,7 +254,7 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
if
block
!=
nil
{
if
block
!=
nil
{
blocks
=
append
(
blocks
,
block
)
blocks
=
append
(
blocks
,
block
)
}
}
if
i
==
maxBlocks
{
if
i
==
downloader
.
MaxBlockFetch
{
break
break
}
}
}
}
...
...
eth/peer.go
View file @
06a04158
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/downloader"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p"
...
@@ -100,8 +101,8 @@ func (p *peer) sendTransaction(tx *types.Transaction) error {
...
@@ -100,8 +101,8 @@ func (p *peer) sendTransaction(tx *types.Transaction) error {
}
}
func
(
p
*
peer
)
requestHashes
(
from
common
.
Hash
)
error
{
func
(
p
*
peer
)
requestHashes
(
from
common
.
Hash
)
error
{
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"[%s] fetching hashes (%d) %x...
\n
"
,
p
.
id
,
maxHashes
,
from
[
:
4
])
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"[%s] fetching hashes (%d) %x...
\n
"
,
p
.
id
,
downloader
.
MaxHashFetch
,
from
[
:
4
])
return
p2p
.
Send
(
p
.
rw
,
GetBlockHashesMsg
,
getBlockHashesMsgData
{
from
,
maxHashes
})
return
p2p
.
Send
(
p
.
rw
,
GetBlockHashesMsg
,
getBlockHashesMsgData
{
from
,
downloader
.
MaxHashFetch
})
}
}
func
(
p
*
peer
)
requestBlocks
(
hashes
[]
common
.
Hash
)
error
{
func
(
p
*
peer
)
requestBlocks
(
hashes
[]
common
.
Hash
)
error
{
...
...
eth/protocol.go
View file @
06a04158
...
@@ -12,8 +12,6 @@ const (
...
@@ -12,8 +12,6 @@ const (
NetworkId
=
0
NetworkId
=
0
ProtocolLength
=
uint64
(
8
)
ProtocolLength
=
uint64
(
8
)
ProtocolMaxMsgSize
=
10
*
1024
*
1024
ProtocolMaxMsgSize
=
10
*
1024
*
1024
maxHashes
=
512
maxBlocks
=
128
)
)
// eth protocol message codes
// eth protocol message codes
...
...
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