def subdispatch_to_initiatortransfer( payment_state: InitiatorPaymentState, initiator_state: InitiatorTransferState, state_change: StateChange, channelidentifiers_to_channels: Dict[ChannelID, NettingChannelState], pseudo_random_generator: random.Random, block_number: BlockNumber, ) -> TransitionResult[Optional[InitiatorTransferState]]: channel_identifier = initiator_state.channel_identifier channel_state = channelidentifiers_to_channels.get(channel_identifier) if not channel_state: return TransitionResult(initiator_state, list()) sub_iteration = initiator.state_transition( initiator_state=initiator_state, state_change=state_change, channel_state=channel_state, pseudo_random_generator=pseudo_random_generator, block_number=block_number, ) if sub_iteration.new_state is None: del payment_state.initiator_transfers[ initiator_state.transfer.lock.secrethash] return sub_iteration
def subdispatch_to_initiatortransfer( payment_state: InitiatorPaymentState, initiator_state: InitiatorTransferState, state_change: StateChange, channelidentifiers_to_channels: ChannelMap, pseudo_random_generator: random.Random, ) -> TransitionResult[InitiatorTransferState]: channel_identifier = initiator_state.channel_identifier channel_state = channelidentifiers_to_channels[initiator_state.transfer_description.initiator].get( channel_identifier) if not channel_state: return TransitionResult(initiator_state, list()) sub_iteration = initiator.state_transition( initiator_state=initiator_state, state_change=state_change, channel_state=channel_state, pseudo_random_generator=pseudo_random_generator, ) if sub_iteration.new_state is None: print(state_change.__repr__()) print("Del 6") del payment_state.initiator_transfers[initiator_state.transfer.lock.secrethash] return sub_iteration
def make_initiator_state( routes, target, amount=factories.UNIT_TRANSFER_AMOUNT, block_number=1, our_address=factories.ADDR, secret_generator=None, identifier=0, token=factories.UNIT_TOKEN_ADDRESS): init_state_change = make_init_statechange( routes, target, amount, block_number, our_address, secret_generator, identifier=identifier, token=token, ) inital_state = None iteration = initiator.state_transition(inital_state, init_state_change) return iteration.new_state