func burnDown(taller, shorter *types.RefHeap, tall, short uint64) (tallRefs, comRefs types.RefSlice) { for ht := tall; ht > short; ht = headHeight(taller) { tallRefs = append(tallRefs, heap.Pop(taller).(types.Ref)) } for shortIdx := 0; !taller.Empty() && headHeight(taller) == short; { tallRef := heap.Pop(taller).(types.Ref) shortPeek := shorter.PeekAt(shortIdx) if types.HeapOrder(tallRef, shortPeek) { tallRefs = append(tallRefs, tallRef) continue } if types.HeapOrder(shortPeek, tallRef) { shortIdx++ continue } d.Chk.True(tallRef.Equals(shortPeek), "Refs should be equal: %s != %s", tallRef.TargetHash(), shortPeek.TargetHash()) heap.Remove(shorter, shortIdx) comRefs = append(comRefs, tallRef) } return }
func headHeight(h *types.RefHeap) uint64 { return h.Peek().Height() }