def handle_report()

in simulation/decai/simulation/contract/incentive/stakeable.py [0:0]


    def handle_report(self, reporter: str, stored_data: StoredData, claimed_by_reporter: bool, prediction) -> float:
        if stored_data.claimable_amount <= 0:
            raise RejectException("There is no reward left to claim.")

        current_time_s = int(self._time())
        if current_time_s - stored_data.time >= self.any_address_claim_wait_time_s:
            # Enough time has passed, give the entire remaining deposit to the reporter.
            self._logger.debug("Giving all remaining deposit to \"%s\".", reporter)
            result = stored_data.claimable_amount
            return result

        # Don't allow someone to claim back their own deposit if their data was wrong.
        # They can still claim it from another address but they will have had to have sent good data from that address.
        if reporter == stored_data.sender:
            raise RejectException("Cannot take your own deposit. Ask for a refund instead.")
        if claimed_by_reporter:
            raise RejectException("Deposit already claimed by reporter.")
        if current_time_s - stored_data.time <= self.refund_time_s:
            raise RejectException("Not enough time has passed.")
        if callable(prediction):
            prediction = prediction()
        if prediction == stored_data.classification:
            raise RejectException("The model should not agree with the contribution.")

        num_good = self.num_good_data_per_user[reporter]
        if num_good <= 0:
            raise RejectException(f"No good data was verified by reporter '{reporter}'.")
        result = stored_data.initial_deposit * num_good / self.total_num_good_data
        # Handle possible rounding errors or if there is too little to divide to reporters.
        if result <= 0 or result > stored_data.claimable_amount:
            result = stored_data.claimable_amount
        return result