Skip to content
Snippets Groups Projects
controller.py 35.2 KiB
Newer Older
  • Learn to ignore specific revisions
  •     return _REDEEMERS[redeemer_kind](section_name, node_config, announcement, reactor)
    
    
    _REDEEMERS = {
    
        u"non": NonRedeemer.make,
    
        u"double-spend": DoubleSpendRedeemer.make,
    
        u"unpaid": UnpaidRedeemer.make,
    
        u"error": ErrorRedeemer.make,
    
    
    
    @inlineCallbacks
    def bracket(first, last, between):
        """
        Invoke an action between two other actions.
    
        :param first: A no-argument function that may return a Deferred.  It is
            called first.
    
        :param last: A no-argument function that may return a Deferred.  It is
            called last.
    
        :param between: A no-argument function that may return a Deferred.  It is
            called after ``first`` is done and completes before ``last`` is called.
    
        :return Deferred: A ``Deferred`` which fires with the result of
            ``between``.
        """
        yield first()
        try:
            result = yield between()
        except GeneratorExit:
            raise
        except:
            info = exc_info()
            yield last()
    
            raise info[0], info[1], info[2]
    
        else:
            yield last()
            returnValue(result)