NatSpec comments added.

This commit is contained in:
Daniel A. Nagy 2015-04-10 15:06:41 +02:00
parent 10c36b065f
commit 08b8d63c0c

View file

@ -1,9 +1,14 @@
/// @title Swarm Distributed Preimage Archive
/// @author Daniel A. Nagy <daniel@ethdev.com>
contract Swarm
{
enum Status {Clean, Suspect, Guilty}
struct Bee {
uint deposit;
uint expiry;
Status status;
}
mapping (address => Bee) swarm;
@ -13,15 +18,27 @@ contract Swarm
return b;
}
/// @notice Sign up as a Swarm node for `time` seconds.
/// No term extension for nodes with non-clean status.
///
/// @dev Guards against term overflow and unauthorized extension,
/// but all funds are added to deposite irrespective of status.
///
/// @param time term of Swarm membership in seconds from now.
function signup(uint time) {
Bee b = swarm[msg.sender];
if(now + time > now) b.expiry = max(b.expiry, now + time);
if(b.status == Clean && now + time > now) {
b.expiry = max(b.expiry, now + time);
}
b.deposit += msg.value;
}
/// @notice Withdraw from Swarm, refund deposit.
///
/// @dev Only allowed with clean status and expired term.
function withdraw() {
Bee b = swarm[msg.sender];
if(now > b.expiry) {
if(now > b.expiry && b.status == clean) {
msg.sender.send(b.deposit);
b.deposit = 0;
}