mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 12:46:44 +00:00
Very preliminary swarm contract.
This commit is contained in:
parent
a77e704b4a
commit
b3af2579d2
1 changed files with 29 additions and 0 deletions
29
bzz/bzzcontract/swarm.sol
Normal file
29
bzz/bzzcontract/swarm.sol
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue