bitcoin/bitcoin — pull request #2098 by Diapolo (2012-12-12 19:01:25+00:00)
Title: add Windows specific optimization to pre-alloc block/undo files

- add AllocateFileRangeWin(), which is used to pre-allocate block/undo files
as a single contignous chunk on disk, so these files are not fragmented
(current master has 95 - 409 fragments for such files, this patch
reduces all those to 1 fragment)

- add GetBlockFile() and GetUndoFile() helper functions, which are a
wrapper for GetDiskFile(), which caches the last used file (separate
cache for the last block and undo file)

I guess the helper functions could be used in other places of the code as well. I have another pull in the pipe, which makes CAutoFile based on an std::fstream and I use these helper functions there, too.

Todo:
- perhaps there is no need for another function name even, so AllocateFileRangeWin() could be changed to AllocateFileRange()
- as I didn't know how big undo files can grow (no MAX_UNDOFILE_SIZE from @sipa ^^), I used the same size for them, as for the block files (MAX_BLOCKFILE_SIZE)