@@ -7,13 +7,11 @@ import (
7
7
"math/rand"
8
8
"time"
9
9
10
- "github.com/ethereum/go-ethereum/core"
11
-
12
10
"github.com/ethereum/go-ethereum/common"
11
+ "github.com/ethereum/go-ethereum/core"
13
12
"github.com/ethereum/go-ethereum/core/types"
14
13
"github.com/ethereum/go-ethereum/logger"
15
14
"github.com/ethereum/go-ethereum/logger/glog"
16
- "github.com/rcrowley/go-metrics"
17
15
"gopkg.in/karalabe/cookiejar.v2/collections/prque"
18
16
)
19
17
@@ -99,14 +97,6 @@ type Fetcher struct {
99
97
// Testing hooks
100
98
fetchingHook func ([]common.Hash ) // Method to call upon starting a block fetch
101
99
importedHook func (* types.Block ) // Method to call upon successful block import
102
-
103
- // Runtime metrics
104
- announceMeter metrics.Meter // Counter for metering the inbound announcements
105
- announceTimer metrics.Timer // Counter and timer for metering the announce forwarding
106
- broadcastMeter metrics.Meter // Counter for metering the inbound propagations
107
- broadcastTimer metrics.Timer // Counter and timer for metering the block forwarding
108
- discardMeter metrics.Meter // Counter for metering the discarded blocks
109
- futureMeter metrics.Meter // Counter for metering future blocks
110
100
}
111
101
112
102
// New creates a block fetcher to retrieve blocks based on hash announcements.
@@ -129,12 +119,6 @@ func New(getBlock blockRetrievalFn, validateBlock blockValidatorFn, broadcastBlo
129
119
chainHeight : chainHeight ,
130
120
insertChain : insertChain ,
131
121
dropPeer : dropPeer ,
132
- announceMeter : metrics .GetOrRegisterMeter ("eth/sync/RemoteAnnounces" , metrics .DefaultRegistry ),
133
- announceTimer : metrics .GetOrRegisterTimer ("eth/sync/LocalAnnounces" , metrics .DefaultRegistry ),
134
- broadcastMeter : metrics .GetOrRegisterMeter ("eth/sync/RemoteBroadcasts" , metrics .DefaultRegistry ),
135
- broadcastTimer : metrics .GetOrRegisterTimer ("eth/sync/LocalBroadcasts" , metrics .DefaultRegistry ),
136
- discardMeter : metrics .GetOrRegisterMeter ("eth/sync/DiscardedBlocks" , metrics .DefaultRegistry ),
137
- futureMeter : metrics .GetOrRegisterMeter ("eth/sync/FutureBlocks" , metrics .DefaultRegistry ),
138
122
}
139
123
}
140
124
@@ -246,7 +230,7 @@ func (f *Fetcher) loop() {
246
230
247
231
case notification := <- f .notify :
248
232
// A block was announced, make sure the peer isn't DOSing us
249
- f . announceMeter .Mark (1 )
233
+ announceMeter .Mark (1 )
250
234
251
235
count := f .announces [notification .origin ] + 1
252
236
if count > hashLimit {
@@ -265,7 +249,7 @@ func (f *Fetcher) loop() {
265
249
266
250
case op := <- f .inject :
267
251
// A direct block insertion was requested, try and fill any pending gaps
268
- f . broadcastMeter .Mark (1 )
252
+ broadcastMeter .Mark (1 )
269
253
f .enqueue (op .origin , op .block )
270
254
271
255
case hash := <- f .done :
@@ -384,7 +368,7 @@ func (f *Fetcher) enqueue(peer string, block *types.Block) {
384
368
// Discard any past or too distant blocks
385
369
if dist := int64 (block .NumberU64 ()) - int64 (f .chainHeight ()); dist < - maxUncleDist || dist > maxQueueDist {
386
370
glog .V (logger .Debug ).Infof ("Peer %s: discarded block #%d [%x], distance %d" , peer , block .NumberU64 (), hash .Bytes ()[:4 ], dist )
387
- f . discardMeter .Mark (1 )
371
+ discardMeter .Mark (1 )
388
372
return
389
373
}
390
374
// Schedule the block for future importing
@@ -423,11 +407,11 @@ func (f *Fetcher) insert(peer string, block *types.Block) {
423
407
switch err := f .validateBlock (block , parent ); err {
424
408
case nil :
425
409
// All ok, quickly propagate to our peers
426
- f . broadcastTimer .UpdateSince (block .ReceivedAt )
410
+ broadcastTimer .UpdateSince (block .ReceivedAt )
427
411
go f .broadcastBlock (block , true )
428
412
429
413
case core .BlockFutureErr :
430
- f . futureMeter .Mark (1 )
414
+ futureMeter .Mark (1 )
431
415
// Weird future block, don't fail, but neither propagate
432
416
433
417
default :
@@ -442,7 +426,7 @@ func (f *Fetcher) insert(peer string, block *types.Block) {
442
426
return
443
427
}
444
428
// If import succeeded, broadcast the block
445
- f . announceTimer .UpdateSince (block .ReceivedAt )
429
+ announceTimer .UpdateSince (block .ReceivedAt )
446
430
go f .broadcastBlock (block , false )
447
431
448
432
// Invoke the testing hook if needed
0 commit comments