Actually that's a separate variable which is nBlockMaxWeight (4000000) minus 4000 units. It's just checking if the block is "almost full" of transactions (meaning, weight of at least 3996000, which is 99.9% capacity).
The maximum weight itself is defined as 4000000 in consensus.h
here.
Oh. That makes so much more sense now.
Thanks!
the code nBlockSize 1000 is in miner.cpp in versions 0.9.4
Is it in kB ?
Bytes. But it doesn't concern the whole Block size. I realised I've read the whole code wrongly and I had to read it again.
The 1000 value you see isn't the actual block size. The whole point for that line of code is to reserve the coinbase transaction, which they assume to be 1000bytes. If you read the code later on, it would prevent the client from including too many transactions, such that they are unable to include the coinbase transaction.