Is this Blacklist Solidity code Correct?

How is this code below correct? I have seen several contract use this Code.
I am thinking, if sender account is blacklisted but recipient account is not blacklisted, this code will proceed, even though to my thinking, it ought not to proceed.

require(!_isBlacklisted[recipient] && !_isBlacklisted[sender], 'Account Blacklisted');

what if we simply use the below code,

require(!_isBlacklisted[sender], 'Sender Account Blacklisted');
require(!_isBlacklisted[recipient], 'Reciever Account Blacklisted');

Is it more expensive to use multiple require, but will expensive be considered instead of code correctness?

we ae using && operator here
(condition1 && condition2) means both the conditions should be satisfied

1 Like

Does it mean if one of the condition is not true, then, this won't work right?

So, if an address is not blacklisted and the other is blacklisted, the transfer will procees right? Since both conditions must be true.

Have you looked at my code I suggest as more effective?

Both are doing the same thing, just the difference is that the second one tells which account is blacklisted, in case of first one we don't know.
So which is better just depend on the need
I will prefer second if I want to tell which account is blacklisted orfirst one if we just want to save gas fee

1 Like

Sorry, it doesn't seem they are doing the same thing.

If sender is true, and receiver is false, the code will proceed, but in my code, when sender is true, and reveieger is false, the code will revert.