Refuse getting sent the same block when it's already on disk
Description
There is nothing preventing being sent the same block multiple times. As the blocks are verified, a block always stays the same, meaning there is no reason to accept a send request of the same block multiple times (this is a waste of bandwidth)
Solution
In the protocol of send_block_to
there is a ExchangeCode
enum. Add a code that is AlreadyStored
for example. We can't just use RejectBlockSend
because that would result in an error, but the block already stored is actually the result we want, so it should result in an Ok.
On the sender side, in handle_send_block_exchange_sender_side_inner
in the first answer simply match on the new AlreadyStored
variant and return a Ok
On the receiver side, check if the block is already on disk before checking if enough room is available for the block.