Commit 5ad62a7e authored by smartcontracts's avatar smartcontracts Committed by GitHub

cleanup: Minor cleanup to address manager (#372)

Co-authored-by: default avatarMaurelian <maurelian@protonmail.ch>
parent b42fe20c
......@@ -18,9 +18,10 @@ contract Lib_AddressManager is Ownable {
address _newAddress
);
/*******************************************
* Contract Variables: Internal Accounting *
*******************************************/
/*************
* Variables *
*************/
mapping (bytes32 => address) private addresses;
......@@ -29,6 +30,11 @@ contract Lib_AddressManager is Ownable {
* Public Functions *
********************/
/**
* Changes the address associated with a particular name.
* @param _name String name to associate an address with.
* @param _address Address to associate with the name.
*/
function setAddress(
string memory _name,
address _address
......@@ -36,16 +42,27 @@ contract Lib_AddressManager is Ownable {
public
onlyOwner
{
emit AddressSet(_name, _address);
addresses[_getNameHash(_name)] = _address;
emit AddressSet(
_name,
_address
);
}
/**
* Retrieves the address associated with a given name.
* @param _name Name to retrieve an address for.
* @return Address associated with the given name.
*/
function getAddress(
string memory _name
)
public
view
returns (address)
returns (
address
)
{
return addresses[_getNameHash(_name)];
}
......@@ -55,13 +72,18 @@ contract Lib_AddressManager is Ownable {
* Internal Functions *
**********************/
/**
* Computes the hash of a name.
* @param _name Name to compute a hash for.
* @return Hash of the given name.
*/
function _getNameHash(
string memory _name
)
internal
pure
returns (
bytes32 _hash
bytes32
)
{
return keccak256(abi.encodePacked(_name));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment