mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 12:46:44 +00:00
NatSpec comments added.
This commit is contained in:
parent
10c36b065f
commit
08b8d63c0c
1 changed files with 19 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue