@@ -811,6 +811,8 @@ func (s *Syncer) assignAccountTasks(cancel chan struct{}) {
811
811
if idle == "" {
812
812
return
813
813
}
814
+ peer := s .peers [idle ]
815
+
814
816
// Matched a pending task to an idle peer, allocate a unique request id
815
817
var reqid uint64
816
818
for {
@@ -834,22 +836,22 @@ func (s *Syncer) assignAccountTasks(cancel chan struct{}) {
834
836
task : task ,
835
837
}
836
838
req .timeout = time .AfterFunc (requestTimeout , func () {
837
- log . Debug ("Account range request timed out" )
839
+ peer . Log (). Debug ("Account range request timed out" , "reqid" , reqid )
838
840
s .scheduleRevertAccountRequest (req )
839
841
})
840
842
s .accountReqs [reqid ] = req
841
843
delete (s .accountIdlers , idle )
842
844
843
845
s .pend .Add (1 )
844
- go func (peer SyncPeer , root common.Hash ) {
846
+ go func (root common.Hash ) {
845
847
defer s .pend .Done ()
846
848
847
849
// Attempt to send the remote request and revert if it fails
848
850
if err := peer .RequestAccountRange (reqid , root , req .origin , req .limit , maxRequestSize ); err != nil {
849
851
peer .Log ().Debug ("Failed to request account range" , "err" , err )
850
852
s .scheduleRevertAccountRequest (req )
851
853
}
852
- }(s .peers [ idle ], s . root ) // We're in the lock, peers[id] surely exists
854
+ }(s .root )
853
855
854
856
// Inject the request into the task to block further assignments
855
857
task .req = req
@@ -891,6 +893,8 @@ func (s *Syncer) assignBytecodeTasks(cancel chan struct{}) {
891
893
if idle == "" {
892
894
return
893
895
}
896
+ peer := s .peers [idle ]
897
+
894
898
// Matched a pending task to an idle peer, allocate a unique request id
895
899
var reqid uint64
896
900
for {
@@ -921,22 +925,22 @@ func (s *Syncer) assignBytecodeTasks(cancel chan struct{}) {
921
925
task : task ,
922
926
}
923
927
req .timeout = time .AfterFunc (requestTimeout , func () {
924
- log . Debug ("Bytecode request timed out" )
928
+ peer . Log (). Debug ("Bytecode request timed out" , "reqid" , reqid )
925
929
s .scheduleRevertBytecodeRequest (req )
926
930
})
927
931
s .bytecodeReqs [reqid ] = req
928
932
delete (s .bytecodeIdlers , idle )
929
933
930
934
s .pend .Add (1 )
931
- go func (peer SyncPeer ) {
935
+ go func () {
932
936
defer s .pend .Done ()
933
937
934
938
// Attempt to send the remote request and revert if it fails
935
939
if err := peer .RequestByteCodes (reqid , hashes , maxRequestSize ); err != nil {
936
940
log .Debug ("Failed to request bytecodes" , "err" , err )
937
941
s .scheduleRevertBytecodeRequest (req )
938
942
}
939
- }(s . peers [ idle ]) // We're in the lock, peers[id] surely exists
943
+ }()
940
944
}
941
945
}
942
946
@@ -976,6 +980,8 @@ func (s *Syncer) assignStorageTasks(cancel chan struct{}) {
976
980
if idle == "" {
977
981
return
978
982
}
983
+ peer := s .peers [idle ]
984
+
979
985
// Matched a pending task to an idle peer, allocate a unique request id
980
986
var reqid uint64
981
987
for {
@@ -1045,14 +1051,14 @@ func (s *Syncer) assignStorageTasks(cancel chan struct{}) {
1045
1051
req .limit = subtask .Last
1046
1052
}
1047
1053
req .timeout = time .AfterFunc (requestTimeout , func () {
1048
- log . Debug ("Storage request timed out" )
1054
+ peer . Log (). Debug ("Storage request timed out" , "reqid" , reqid )
1049
1055
s .scheduleRevertStorageRequest (req )
1050
1056
})
1051
1057
s .storageReqs [reqid ] = req
1052
1058
delete (s .storageIdlers , idle )
1053
1059
1054
1060
s .pend .Add (1 )
1055
- go func (peer SyncPeer , root common.Hash ) {
1061
+ go func (root common.Hash ) {
1056
1062
defer s .pend .Done ()
1057
1063
1058
1064
// Attempt to send the remote request and revert if it fails
@@ -1064,7 +1070,7 @@ func (s *Syncer) assignStorageTasks(cancel chan struct{}) {
1064
1070
log .Debug ("Failed to request storage" , "err" , err )
1065
1071
s .scheduleRevertStorageRequest (req )
1066
1072
}
1067
- }(s .peers [ idle ], s . root ) // We're in the lock, peers[id] surely exists
1073
+ }(s .root )
1068
1074
1069
1075
// Inject the request into the subtask to block further assignments
1070
1076
if subtask != nil {
@@ -1121,6 +1127,8 @@ func (s *Syncer) assignTrienodeHealTasks(cancel chan struct{}) {
1121
1127
if idle == "" {
1122
1128
return
1123
1129
}
1130
+ peer := s .peers [idle ]
1131
+
1124
1132
// Matched a pending task to an idle peer, allocate a unique request id
1125
1133
var reqid uint64
1126
1134
for {
@@ -1160,22 +1168,22 @@ func (s *Syncer) assignTrienodeHealTasks(cancel chan struct{}) {
1160
1168
task : s .healer ,
1161
1169
}
1162
1170
req .timeout = time .AfterFunc (requestTimeout , func () {
1163
- log . Debug ("Trienode heal request timed out" )
1171
+ peer . Log (). Debug ("Trienode heal request timed out" , "reqid" , reqid )
1164
1172
s .scheduleRevertTrienodeHealRequest (req )
1165
1173
})
1166
1174
s .trienodeHealReqs [reqid ] = req
1167
1175
delete (s .trienodeHealIdlers , idle )
1168
1176
1169
1177
s .pend .Add (1 )
1170
- go func (peer SyncPeer , root common.Hash ) {
1178
+ go func (root common.Hash ) {
1171
1179
defer s .pend .Done ()
1172
1180
1173
1181
// Attempt to send the remote request and revert if it fails
1174
1182
if err := peer .RequestTrieNodes (reqid , root , pathsets , maxRequestSize ); err != nil {
1175
1183
log .Debug ("Failed to request trienode healers" , "err" , err )
1176
1184
s .scheduleRevertTrienodeHealRequest (req )
1177
1185
}
1178
- }(s .peers [ idle ], s . root ) // We're in the lock, peers[id] surely exists
1186
+ }(s .root )
1179
1187
}
1180
1188
}
1181
1189
@@ -1227,6 +1235,8 @@ func (s *Syncer) assignBytecodeHealTasks(cancel chan struct{}) {
1227
1235
if idle == "" {
1228
1236
return
1229
1237
}
1238
+ peer := s .peers [idle ]
1239
+
1230
1240
// Matched a pending task to an idle peer, allocate a unique request id
1231
1241
var reqid uint64
1232
1242
for {
@@ -1258,22 +1268,22 @@ func (s *Syncer) assignBytecodeHealTasks(cancel chan struct{}) {
1258
1268
task : s .healer ,
1259
1269
}
1260
1270
req .timeout = time .AfterFunc (requestTimeout , func () {
1261
- log . Debug ("Bytecode heal request timed out" )
1271
+ peer . Log (). Debug ("Bytecode heal request timed out" , "reqid" , reqid )
1262
1272
s .scheduleRevertBytecodeHealRequest (req )
1263
1273
})
1264
1274
s .bytecodeHealReqs [reqid ] = req
1265
1275
delete (s .bytecodeHealIdlers , idle )
1266
1276
1267
1277
s .pend .Add (1 )
1268
- go func (peer SyncPeer ) {
1278
+ go func () {
1269
1279
defer s .pend .Done ()
1270
1280
1271
1281
// Attempt to send the remote request and revert if it fails
1272
1282
if err := peer .RequestByteCodes (reqid , hashes , maxRequestSize ); err != nil {
1273
1283
log .Debug ("Failed to request bytecode healers" , "err" , err )
1274
1284
s .scheduleRevertBytecodeHealRequest (req )
1275
1285
}
1276
- }(s . peers [ idle ]) // We're in the lock, peers[id] surely exists
1286
+ }()
1277
1287
}
1278
1288
}
1279
1289
0 commit comments