Ejemplo n.º 1
0
    def execute(self,
                block_height,
                invoker_uri='',
                channel_name='',
                invoker_key='',
                nonce=None):
        """

        :param block_height:
        :param invoker_uri:
        :param channel_name:
        :param trade:
        :param invoker_key:
        :param gwei:
        :return:
        """
        super(ChannelUpdateSettleEvent, self).execute(block_height)

        # close channel event
        # ToDo uncomment below codes in future
        # latest_trade = Channel.latest_confirmed_trade()
        # if isinstance(nonce, int) and int(nonce) == latest_trade.nonce: # or check balance:
        #     self.next_stage()
        #     return

        result = Channel.force_release_rsmc(
            invoker_uri,
            channel_name,
            nonce,
            invoker_key,
            gwei_coef=self.gwei_coef,
            trigger=self.contract_event_api.update_close_channel)

        # set channel settling
        if result is not None and 'success' in result.values():
            Channel.update_channel(self.channel_name,
                                   state=EnumChannelState.SETTLED.name)
            APIStatistics.update_statistics(
                self.wallet_address, state=EnumChannelState.SETTLED.name)
        self.next_stage()
Ejemplo n.º 2
0
    def execute(self,
                block_height,
                invoker_uri='',
                channel_name='',
                nonce=None,
                invoker_key='',
                is_debug=False):
        """

        :param block_height:
        :param invoker_uri:
        :param channel_name:
        :param trade:
        :param invoker_key:
        :param gwei:
        :return:
        """
        super(ChannelForceSettleEvent, self).execute(block_height)

        LOG.debug('parameter: {}, {}, {}, {}'.format(invoker_uri, channel_name,
                                                     nonce, invoker_key))
        LOG.debug('event args: {}, kwargs'.format(self.event_arguments.args,
                                                  self.event_arguments.kwargs))

        # close channel event
        result = Channel.force_release_rsmc(
            invoker_uri,
            channel_name,
            nonce,
            invoker_key,
            gwei_coef=self.gwei_coef,
            trigger=self.contract_event_api.close_channel,
            is_debug=is_debug)

        # set channel settling
        if result is not None and 'success' in result.values():
            Channel.update_channel(self.channel_name,
                                   state=EnumChannelState.SETTLED.name)
            self.next_stage()