I have a contract where I often set stuff for a combination of 2 addresses. Because the parameters addressA and addressB are interchangeable I currently save the information redundantly.
Example:
mapping ( address => mapping ( address => uint256 )) public maxNextUpdateInBlocks;
function configureCurrencyPair(address _currencyA, address _currencyB, uint256 maxNextUpdateInBlocks) public onlyOwner {
maxNextUpdateInBlocks[_currencyA][_currencyB] = maxNextUpdateInBlocks;
maxNextUpdateInBlocks[_currencyB][_currencyA] = maxNextUpdateInBlocks;
}
Can this be improved? I am thinking about a hash of the address combination where it doesn't matter if I hash currencyA+currencyB or currencyB+currencyA
And just set in one line:
maxNextUpdateInBlocks[currencyAB] = maxNextUpdateInBlocks;