File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
internal/libs/libblockdata Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -174,13 +174,19 @@ func GetValidBlockDataFromRpc(blockNumbers []uint64) []*common.BlockData {
174174 numBatches := (totalBlocks + int (rpcBatchSize ) - 1 ) / int (rpcBatchSize )
175175
176176 var wg sync.WaitGroup
177+ maxConcurrentBatches := 4
178+ semaphore := make (chan struct {}, maxConcurrentBatches )
177179
178- // Process blocks in parallel batches
180+ // Process blocks in parallel batches with concurrency limit
179181 for batchIndex := 0 ; batchIndex < numBatches ; batchIndex ++ {
180182 wg .Add (1 )
181183 go func (batchIdx int ) {
182184 defer wg .Done ()
183185
186+ // Acquire semaphore
187+ semaphore <- struct {}{}
188+ defer func () { <- semaphore }()
189+
184190 start := batchIdx * int (rpcBatchSize )
185191 end := min (start + int (rpcBatchSize ), totalBlocks )
186192
You can’t perform that action at this time.
0 commit comments