mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Revert initsync revert (#12431)
* Revert "Revert "BeaconBlocksByRange and BlobSidecarsByRange consistency (#123… (#12426)"
This reverts commit ddc1e48e05.
* fix metrics bug, add batch.next tests
---------
Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
This commit is contained in:
@@ -248,7 +248,7 @@ func (s *Service) sendBatchRootRequest(ctx context.Context, roots [][32]byte, ra
|
||||
if len(bestPeers) == 0 {
|
||||
return nil
|
||||
}
|
||||
roots = s.dedupRoots(roots)
|
||||
roots = dedupRoots(roots)
|
||||
// Randomly choose a peer to query from our best peers. If that peer cannot return
|
||||
// all the requested blocks, we randomly select another peer.
|
||||
pid := bestPeers[randGen.Int()%len(bestPeers)]
|
||||
@@ -456,3 +456,16 @@ func slotToCacheKey(s primitives.Slot) string {
|
||||
b := bytesutil.SlotToBytesBigEndian(s)
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func dedupRoots(roots [][32]byte) [][32]byte {
|
||||
newRoots := make([][32]byte, 0, len(roots))
|
||||
rootMap := make(map[[32]byte]bool, len(roots))
|
||||
for i, r := range roots {
|
||||
if rootMap[r] {
|
||||
continue
|
||||
}
|
||||
rootMap[r] = true
|
||||
newRoots = append(newRoots, roots[i])
|
||||
}
|
||||
return newRoots
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user