Very preliminary swarm contract.

This commit is contained in:
Daniel A. Nagy 2015-04-07 13:53:12 +02:00
parent a77e704b4a
commit b3af2579d2

29
bzz/bzzcontract/swarm.sol Normal file
View file

@ -0,0 +1,29 @@
contract Swarm
{
struct Bee {
uint deposit;
uint expiry;
}
mapping (address => Bee) swarm;
function max(uint a, uint b) private returns (uint c) {
if(a >= b) return a;
return b;
}
function signup(uint time) {
Bee b = swarm[msg.sender];
b.expiry = max(b.expiry, now) + time;
b.deposit += msg.value;
}
function withdraw() {
Bee b = swarm[msg.sender];
if(now > b.expiry) {
msg.sender.send(b.deposit);
}
}
}