DcnRegistry
Manager-Exclusive Functions
Resolver Management
Information Retrieval
Name Storage Mechanism
/// Iteratively calculates the name hash of a list of labels
function labelsHash(
string[] calldata labels
) private view returns (bytes32 node) {
require(labels.length > 1, "Labels length below 2");
for (uint256 i = labels.length; i > 0; i--) {
require(_exists(uint256(node)), "Parent node does not exist");
node = namehash(node, labels[i - 1]);
}
}
/// Calculates the name hash of a label given the parent node
function namehash(
bytes32 node,
string calldata label
) private pure returns (bytes32 hashed) {
require(bytes(label).length != 0, "Empty label");
hashed = keccak256(
abi.encodePacked(node, keccak256(abi.encodePacked(label)))
);
}Last updated