Hah, you learn something new everyday.
In c++, variables can be changed by passing them to functions, thanks to the reference notation.
I checked the validation.cpp file and could only see one place where there is a change to the variable.
It is also changed using this code.
pblocktree->ReadLastBlockFile(nLastBlockFile);
ReadLastBlockFile takes int& nFile as its input.
I thought references like that were inherently constants.
I think this effect is due to the changes to
blockstorage.cpp (including some refactoring away from validation.cpp). The call to ReadLastBlockFile doesn't change the nLastBlockFile global variable. It just targets a local variable in the function.
This means the global variable stays at its default of zero.
This is what allows the node to write to previously completed blk*.dat files rather than only looking at new blk files.
In the Bitcoin Core client, the
call to ReadLastBlockFile has a side effect that initializes the nLastBlockFile variable.
This is a Bitcoin Unlimited only behavior, I think, since Bitcoin Core and Bitcoin ABC haven't made the changes.