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
821e01b0
Commit
821e01b0
authored
Jun 19, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/geth, eth/fetcher: initial metrics support
Conflicts: cmd/geth/admin.go
parent
22c7ce01
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
974 additions
and
0 deletions
+974
-0
admin.go
cmd/geth/admin.go
+960
-0
fetcher.go
eth/fetcher/fetcher.go
+14
-0
No files found.
cmd/geth/admin.go
0 → 100644
View file @
821e01b0
This diff is collapsed.
Click to expand it.
eth/fetcher/fetcher.go
View file @
821e01b0
...
...
@@ -7,6 +7,8 @@ import (
"math/rand"
"time"
"github.com/rcrowley/go-metrics"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/logger"
...
...
@@ -96,6 +98,11 @@ type Fetcher struct {
// Testing hooks
fetchingHook
func
([]
common
.
Hash
)
// Method to call upon starting a block fetch
importedHook
func
(
*
types
.
Block
)
// Method to call upon successful block import
// Runtime metrics
announceStats
metrics
.
Meter
broadcastStats
metrics
.
Meter
discardStats
metrics
.
Meter
}
// New creates a block fetcher to retrieve blocks based on hash announcements.
...
...
@@ -118,6 +125,9 @@ func New(getBlock blockRetrievalFn, validateBlock blockValidatorFn, broadcastBlo
chainHeight
:
chainHeight
,
insertChain
:
insertChain
,
dropPeer
:
dropPeer
,
announceStats
:
metrics
.
GetOrRegisterMeter
(
"eth/Announced Blocks"
,
metrics
.
DefaultRegistry
),
broadcastStats
:
metrics
.
GetOrRegisterMeter
(
"eth/Propagated Blocks"
,
metrics
.
DefaultRegistry
),
discardStats
:
metrics
.
GetOrRegisterMeter
(
"eth/Discarded Blocks"
,
metrics
.
DefaultRegistry
),
}
}
...
...
@@ -229,6 +239,8 @@ func (f *Fetcher) loop() {
case
notification
:=
<-
f
.
notify
:
// A block was announced, make sure the peer isn't DOSing us
f
.
announceStats
.
Mark
(
1
)
count
:=
f
.
announces
[
notification
.
origin
]
+
1
if
count
>
hashLimit
{
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Peer %s: exceeded outstanding announces (%d)"
,
notification
.
origin
,
hashLimit
)
...
...
@@ -246,6 +258,7 @@ func (f *Fetcher) loop() {
case
op
:=
<-
f
.
inject
:
// A direct block insertion was requested, try and fill any pending gaps
f
.
broadcastStats
.
Mark
(
1
)
f
.
enqueue
(
op
.
origin
,
op
.
block
)
case
hash
:=
<-
f
.
done
:
...
...
@@ -364,6 +377,7 @@ func (f *Fetcher) enqueue(peer string, block *types.Block) {
// Discard any past or too distant blocks
if
dist
:=
int64
(
block
.
NumberU64
())
-
int64
(
f
.
chainHeight
());
dist
<
-
maxUncleDist
||
dist
>
maxQueueDist
{
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Peer %s: discarded block #%d [%x], distance %d"
,
peer
,
block
.
NumberU64
(),
hash
.
Bytes
()[
:
4
],
dist
)
f
.
discardStats
.
Mark
(
1
)
return
}
// Schedule the block for future importing
...
...
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