After user for a long time codes from Open zeppelin I found comething weird. Usually, they use public functions which only use is to call an internal function with the same name but with _ in front.
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0), "Adress can't be 0x0000...");
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
This repeats in a lot of contracts. Why do they do that? Is it a security thing or am I missing something. For me right now, the only thing that this gives me is more gas cost.