@@ -34,13 +34,14 @@ import (
34
34
// stateReq represents a batch of state fetch requests grouped together into
35
35
// a single data retrieval network packet.
36
36
type stateReq struct {
37
- nItems uint16 // Number of items requested for download (max is 384, so uint16 is sufficient)
38
- tasks map [common.Hash ]* stateTask // Download tasks to track previous attempts
39
- timeout time.Duration // Maximum round trip time for this to complete
40
- timer * time.Timer // Timer to fire when the RTT timeout expires
41
- peer * peerConnection // Peer that we're requesting from
42
- response [][]byte // Response data of the peer (nil for timeouts)
43
- dropped bool // Flag whether the peer dropped off early
37
+ nItems uint16 // Number of items requested for download (max is 384, so uint16 is sufficient)
38
+ tasks map [common.Hash ]* stateTask // Download tasks to track previous attempts
39
+ timeout time.Duration // Maximum round trip time for this to complete
40
+ timer * time.Timer // Timer to fire when the RTT timeout expires
41
+ peer * peerConnection // Peer that we're requesting from
42
+ delivered time.Time // Time when the packet was delivered (independent when we process it)
43
+ response [][]byte // Response data of the peer (nil for timeouts)
44
+ dropped bool // Flag whether the peer dropped off early
44
45
}
45
46
46
47
// timedOut returns if this request timed out.
@@ -148,6 +149,7 @@ func (d *Downloader) runStateSync(s *stateSync) *stateSync {
148
149
// Finalize the request and queue up for processing
149
150
req .timer .Stop ()
150
151
req .response = pack .(* statePack ).states
152
+ req .delivered = time .Now ()
151
153
152
154
finished = append (finished , req )
153
155
delete (active , pack .PeerId ())
@@ -349,7 +351,6 @@ func (s *stateSync) loop() (err error) {
349
351
return errCanceled
350
352
351
353
case req := <- s .deliver :
352
- deliveryTime := time .Now ()
353
354
// Response, disconnect or timeout triggered, drop the peer if stalling
354
355
log .Trace ("Received node data response" , "peer" , req .peer .id , "count" , len (req .response ), "dropped" , req .dropped , "timeout" , ! req .dropped && req .timedOut ())
355
356
if req .nItems <= 2 && ! req .dropped && req .timedOut () {
@@ -376,7 +377,7 @@ func (s *stateSync) loop() (err error) {
376
377
}
377
378
// Process all the received blobs and check for stale delivery
378
379
delivered , err := s .process (req )
379
- req .peer .SetNodeDataIdle (delivered , deliveryTime )
380
+ req .peer .SetNodeDataIdle (delivered , req . delivered )
380
381
if err != nil {
381
382
log .Warn ("Node data write error" , "err" , err )
382
383
return err
0 commit comments