forked from ensdomains/ens
-
Notifications
You must be signed in to change notification settings - Fork 2
/
TestRegistrar.sol
38 lines (32 loc) · 1.07 KB
/
TestRegistrar.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
pragma solidity ^0.4.0;
import 'interface.sol';
/**
* A registrar that allocates subdomains to the first person to claim them, but
* expires registrations a fixed period after they're initially claimed.
*/
contract TestRegistrar {
uint constant registrationPeriod = 4 weeks;
AbstractENS public ens;
bytes32 public rootNode;
mapping(bytes32=>uint) public expiryTimes;
/**
* Constructor.
* @param ensAddr The address of the ENS registry.
* @param node The node that this registrar administers.
*/
function TestRegistrar(address ensAddr, bytes32 node) {
ens = AbstractENS(ensAddr);
rootNode = node;
}
/**
* Register a name that's not currently registered
* @param subnode The hash of the label to register.
* @param owner The address of the new owner.
*/
function register(bytes32 subnode, address owner) {
if(expiryTimes[subnode] >= now)
throw;
expiryTimes[subnode] = now + registrationPeriod;
ens.setSubnodeOwner(rootNode, subnode, owner);
}
}