Massive code cleanup (#10913)

* Massive code cleanup

* fix test issues

* remove GetGenesis mock expectations

* unused receiver

* rename unused params

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Radosław Kapka
2022-06-27 15:34:38 +02:00
committed by GitHub
parent 9216be7d43
commit 7f56ac6355
158 changed files with 1020 additions and 1177 deletions

View File

@@ -57,16 +57,16 @@ func (s *Service) processPendingBlocks(ctx context.Context) error {
if err := s.validatePendingSlots(); err != nil {
return errors.Wrap(err, "could not validate pending slots")
}
slots := s.sortedPendingSlots()
ss := s.sortedPendingSlots()
var parentRoots [][32]byte
span.AddAttributes(
trace.Int64Attribute("numSlots", int64(len(slots))),
trace.Int64Attribute("numSlots", int64(len(ss))),
trace.Int64Attribute("numPeers", int64(len(pids))),
)
randGen := rand.NewGenerator()
for _, slot := range slots {
for _, slot := range ss {
// process the blocks during their respective slot.
// otherwise wait for the right slot to process the block.
if slot > s.cfg.chain.CurrentSlot() {
@@ -257,15 +257,15 @@ func (s *Service) sortedPendingSlots() []types.Slot {
items := s.slotToPendingBlocks.Items()
slots := make([]types.Slot, 0, len(items))
ss := make([]types.Slot, 0, len(items))
for k := range items {
slot := cacheKeyToSlot(k)
slots = append(slots, slot)
ss = append(ss, slot)
}
sort.Slice(slots, func(i, j int) bool {
return slots[i] < slots[j]
sort.Slice(ss, func(i, j int) bool {
return ss[i] < ss[j]
})
return slots
return ss
}
// validatePendingSlots validates the pending blocks