What is a Stratum "mining.set_difficulty" command for? On the Stratum protocol the server may issue the following notification:

{ "id": null, "method": "mining.set_difficulty", "params": [2]}


What is this difficulty used for? from my understanding the the difficulty is sent with the mining job as an encoded difficulty.

Source:
https://slushpool.com/help/manual/stratum-protocol
The command is telling the miner not to send shares below the requested difficulty. If they were to send every difficulty 1 share for example, many pieces of hardware would be attempting to send hundreds of thousands of results a second. It’s simply flood control, and the only reason to send block shares at all (that are too low of a difficulty to be a block) is to prove to the remote stratum server that you’re doing work worth paying. 

Many pools clamp at a lower bound of many tens of thousands of difficulty as of 2017, and many pieces of hardware aren’t even able to produce blocks with a lower difficulty than that. The miner really only needs to send share proofs every few minutes at most for the remote pool to have a reasonable confidence that they are mining at a particular speed for payout purposes.