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