From 7c067a348262fb7a96004f97e977ae18f230c202 Mon Sep 17 00:00:00 2001 From: "Daniel A. Nagy" Date: Thu, 7 May 2015 18:32:04 +0200 Subject: [PATCH] Reporting mechanism implemented in part. --- bzz/bzzcontract/swarm.sol | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/bzz/bzzcontract/swarm.sol b/bzz/bzzcontract/swarm.sol index 2dd3345e56..e95655647e 100644 --- a/bzz/bzzcontract/swarm.sol +++ b/bzz/bzzcontract/swarm.sol @@ -12,6 +12,7 @@ contract Swarm uint expiry; // expiration time of the deposit bytes32 missing; // member accused of losing this swarm chunk uint deadline; // block number before which chunk must be presented + address reporter; // receipt reported by this address } mapping (address => Bee) swarm; @@ -106,8 +107,31 @@ contract Swarm Bee b = swarm[signer]; b.missing = swarmHash; b.deadline = block.number + GRACE; + b.reporter = msg.sender; Report(signer); } + + /// @notice Present a chunk in order to avoid losing deposit. + /// + /// @param chunk chunk data + function presentMissingChunk(bytes chunk) external { + bytes32 swarmHash = sha3(chunk); + presentedChunks[swarmHash] = block.number; + } + + /// @notice Determine guilty status of address `addr`. + /// No change in state. + /// + /// @dev Definition of guilty is failing to present missing chunk within grace period. + /// + /// @param addr queried address. + /// + /// @return true, if status is "Guilty". + function isGuilty(address addr) returns (bool g){ + if(isClean(addr)) return false; + Bee b = swarm[addr]; + return b.deadline < block.number; + } /// @notice Determine if the deposit for `addr` is unaccessible until `time`. /// No change in state.