示例#1
0
 def GetAvailableClaimTotal(self):
     """
     Gets the total amount of Gas that this wallet is able to claim at a given moment
     Returns:
         Fixed8: the amount of Gas available to claim as a Fixed8 number
     """
     coinrefs = [coin.Reference for coin in self.GetUnclaimedCoins()]
     bonus = Blockchain.CalculateBonusIgnoreClaimed(coinrefs, True)
     return bonus
示例#2
0
    def Verify(self, mempool):
        """
        Verify the transaction.

        Args:
            mempool:

        Returns:
            bool: True if verified. False otherwise.
        """
        if not super(ClaimTransaction, self).Verify(mempool):
            return False

        # wat does this do
        # get all claim transactinos from mempool list
        # that are not this claim
        # and gather all the claims of those claim transactions
        # and see if they intersect the claims of this transaction
        # and if that number is greater than zero that we do not verify
        # (now, to do that in python)
        # if (mempool.OfType < ClaimTransaction > ().Where(p => p != this).SelectMany(p= > p.Claims).Intersect(Claims).Count() > 0)
        # return false;

        # im sorry about the below
        otherclaimTxs = [
            tx for tx in mempool if tx is ClaimTransaction and tx is not self
        ]
        for other in otherclaimTxs:
            # check to see if the length of the intersection between this objects claim's and the other txs claims is > 0
            if len([
                    list(filter(lambda x: x in self.Claims, otherClaims))
                    for otherClaims in other.Claims
            ]):
                return False

        txResult = None
        for tx in self.GetTransactionResults():
            if tx.AssetId == Blockchain.SystemCoin().Hash:
                txResult = tx
                break

        if txResult is None or txResult.Amount > Fixed8(0):
            return False

        try:
            return Blockchain.CalculateBonusIgnoreClaimed(
                self.Claims, False) == -txResult.Amount

        except Exception as e:
            logger.error('Could not calculate bonus: %s ' % e)

        return False