What I am dreaming of is a version that can repair damaged files
Lets start thinking about rational ways to implement that:
For example the prefragmentation - Why ?
The xml file is indeed filled with 6-700 entries of one megabyte segments before ever realizing need for that - that can't be resource efficient - I recommend a segment linked list that in case a new candidate is found can respond with the largest unassigned segment or half of the largest segment not currently being downloaded. or if that is not available on the fly splits the largest segment even if it is in download proceedings and not smaller than the minimum size. Of course the linked list can help reposes segments that never started and are overrun by a well loading one. Sure its already implemented very similar... Just this fragment first algorithmic seems unnecessary complicated to me !
Ok and what does it have to do with damaged files ?
Keep a log of the downloaded segments (even from whom) and then later allow the user (initially manually) to question any segment and request Phex to veryfy it by getting it again ... How about that ? Soon enough we may be able to automate that by implementation of a specific request Segment Sums protocol !
Thanks all for your Great Work !