@@ -2248,14 +2248,18 @@ func (s *Syncer) OnAccounts(peer SyncPeer, id uint64, hashes []common.Hash, acco
2248
2248
// Whether or not the response is valid, we can mark the peer as idle and
2249
2249
// notify the scheduler to assign a new task. If the response is invalid,
2250
2250
// we'll drop the peer in a bit.
2251
+ defer func () {
2252
+ s .lock .Lock ()
2253
+ defer s .lock .Unlock ()
2254
+ if _ , ok := s .peers [peer .ID ()]; ok {
2255
+ s .accountIdlers [peer .ID ()] = struct {}{}
2256
+ }
2257
+ select {
2258
+ case s .update <- struct {}{}:
2259
+ default :
2260
+ }
2261
+ }()
2251
2262
s .lock .Lock ()
2252
- if _ , ok := s .peers [peer .ID ()]; ok {
2253
- s .accountIdlers [peer .ID ()] = struct {}{}
2254
- }
2255
- select {
2256
- case s .update <- struct {}{}:
2257
- default :
2258
- }
2259
2263
// Ensure the response is for a valid request
2260
2264
req , ok := s .accountReqs [id ]
2261
2265
if ! ok {
@@ -2360,14 +2364,18 @@ func (s *Syncer) onByteCodes(peer SyncPeer, id uint64, bytecodes [][]byte) error
2360
2364
// Whether or not the response is valid, we can mark the peer as idle and
2361
2365
// notify the scheduler to assign a new task. If the response is invalid,
2362
2366
// we'll drop the peer in a bit.
2367
+ defer func () {
2368
+ s .lock .Lock ()
2369
+ defer s .lock .Unlock ()
2370
+ if _ , ok := s .peers [peer .ID ()]; ok {
2371
+ s .bytecodeIdlers [peer .ID ()] = struct {}{}
2372
+ }
2373
+ select {
2374
+ case s .update <- struct {}{}:
2375
+ default :
2376
+ }
2377
+ }()
2363
2378
s .lock .Lock ()
2364
- if _ , ok := s .peers [peer .ID ()]; ok {
2365
- s .bytecodeIdlers [peer .ID ()] = struct {}{}
2366
- }
2367
- select {
2368
- case s .update <- struct {}{}:
2369
- default :
2370
- }
2371
2379
// Ensure the response is for a valid request
2372
2380
req , ok := s .bytecodeReqs [id ]
2373
2381
if ! ok {
@@ -2469,14 +2477,18 @@ func (s *Syncer) OnStorage(peer SyncPeer, id uint64, hashes [][]common.Hash, slo
2469
2477
// Whether or not the response is valid, we can mark the peer as idle and
2470
2478
// notify the scheduler to assign a new task. If the response is invalid,
2471
2479
// we'll drop the peer in a bit.
2480
+ defer func () {
2481
+ s .lock .Lock ()
2482
+ defer s .lock .Unlock ()
2483
+ if _ , ok := s .peers [peer .ID ()]; ok {
2484
+ s .storageIdlers [peer .ID ()] = struct {}{}
2485
+ }
2486
+ select {
2487
+ case s .update <- struct {}{}:
2488
+ default :
2489
+ }
2490
+ }()
2472
2491
s .lock .Lock ()
2473
- if _ , ok := s .peers [peer .ID ()]; ok {
2474
- s .storageIdlers [peer .ID ()] = struct {}{}
2475
- }
2476
- select {
2477
- case s .update <- struct {}{}:
2478
- default :
2479
- }
2480
2492
// Ensure the response is for a valid request
2481
2493
req , ok := s .storageReqs [id ]
2482
2494
if ! ok {
@@ -2596,14 +2608,18 @@ func (s *Syncer) OnTrieNodes(peer SyncPeer, id uint64, trienodes [][]byte) error
2596
2608
// Whether or not the response is valid, we can mark the peer as idle and
2597
2609
// notify the scheduler to assign a new task. If the response is invalid,
2598
2610
// we'll drop the peer in a bit.
2611
+ defer func () {
2612
+ s .lock .Lock ()
2613
+ defer s .lock .Unlock ()
2614
+ if _ , ok := s .peers [peer .ID ()]; ok {
2615
+ s .trienodeHealIdlers [peer .ID ()] = struct {}{}
2616
+ }
2617
+ select {
2618
+ case s .update <- struct {}{}:
2619
+ default :
2620
+ }
2621
+ }()
2599
2622
s .lock .Lock ()
2600
- if _ , ok := s .peers [peer .ID ()]; ok {
2601
- s .trienodeHealIdlers [peer .ID ()] = struct {}{}
2602
- }
2603
- select {
2604
- case s .update <- struct {}{}:
2605
- default :
2606
- }
2607
2623
// Ensure the response is for a valid request
2608
2624
req , ok := s .trienodeHealReqs [id ]
2609
2625
if ! ok {
@@ -2691,14 +2707,18 @@ func (s *Syncer) onHealByteCodes(peer SyncPeer, id uint64, bytecodes [][]byte) e
2691
2707
// Whether or not the response is valid, we can mark the peer as idle and
2692
2708
// notify the scheduler to assign a new task. If the response is invalid,
2693
2709
// we'll drop the peer in a bit.
2710
+ defer func () {
2711
+ s .lock .Lock ()
2712
+ defer s .lock .Unlock ()
2713
+ if _ , ok := s .peers [peer .ID ()]; ok {
2714
+ s .bytecodeHealIdlers [peer .ID ()] = struct {}{}
2715
+ }
2716
+ select {
2717
+ case s .update <- struct {}{}:
2718
+ default :
2719
+ }
2720
+ }()
2694
2721
s .lock .Lock ()
2695
- if _ , ok := s .peers [peer .ID ()]; ok {
2696
- s .bytecodeHealIdlers [peer .ID ()] = struct {}{}
2697
- }
2698
- select {
2699
- case s .update <- struct {}{}:
2700
- default :
2701
- }
2702
2722
// Ensure the response is for a valid request
2703
2723
req , ok := s .bytecodeHealReqs [id ]
2704
2724
if ! ok {
0 commit comments