예제 #1
0
파일: pull.go 프로젝트: willhite/noms-old
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
}
예제 #2
0
파일: pull.go 프로젝트: willhite/noms-old
func headHeight(h *types.RefHeap) uint64 {
	return h.Peek().Height()
}