(
self, raiden: "RaidenService", chain_state: ChainState, events: List[Event]
)
| 165 | |
| 166 | class RaidenEventHandler(EventHandler): |
| 167 | def on_raiden_events( |
| 168 | self, raiden: "RaidenService", chain_state: ChainState, events: List[Event] |
| 169 | ) -> None: # pragma: no unittest |
| 170 | |
| 171 | message_queues: Dict[ |
| 172 | QueueIdentifier, List[Tuple[Message, Optional[AddressMetadata]]] |
| 173 | ] = defaultdict(list) |
| 174 | |
| 175 | event_handler_map: Dict[Any, List] = { |
| 176 | SendLockExpired: [self.handle_send_lockexpired, [message_queues]], |
| 177 | SendLockedTransfer: [self.handle_send_lockedtransfer, [message_queues]], |
| 178 | SendSecretReveal: [self.handle_send_secretreveal, [message_queues]], |
| 179 | SendUnlock: [self.handle_send_balanceproof, [message_queues]], |
| 180 | SendSecretRequest: [self.handle_send_secretrequest, [chain_state, message_queues]], |
| 181 | SendWithdrawRequest: [self.handle_send_withdrawrequest, [message_queues]], |
| 182 | SendWithdrawConfirmation: [self.handle_send_withdraw, [message_queues]], |
| 183 | SendWithdrawExpired: [self.handle_send_withdrawexpired, [message_queues]], |
| 184 | SendProcessed: [self.handle_send_processed, [message_queues]], |
| 185 | EventPaymentSentSuccess: [self.handle_paymentsentsuccess, []], |
| 186 | EventPaymentSentFailed: [self.handle_paymentsentfailed, []], |
| 187 | EventUnlockFailed: [self.handle_unlockfailed, []], |
| 188 | EventInvalidSecretRequest: [self.handle_invalidsecretrequest, []], |
| 189 | ContractSendSecretReveal: [self.handle_contract_send_secretreveal, []], |
| 190 | ContractSendChannelClose: [self.handle_contract_send_channelclose, [chain_state]], |
| 191 | ContractSendChannelUpdateTransfer: [self.handle_contract_send_channelupdate, []], |
| 192 | ContractSendChannelBatchUnlock: [ |
| 193 | self.handle_contract_send_channelunlock, |
| 194 | [chain_state], |
| 195 | ], |
| 196 | ContractSendChannelSettle: [self.handle_contract_send_channelsettle, []], |
| 197 | ContractSendChannelWithdraw: [self.handle_contract_send_channelwithdraw, []], |
| 198 | ContractSendChannelCoopSettle: [self.handle_contract_send_coopsettle, []], |
| 199 | UpdateServicesAddresses: [self.handle_update_services_addresses, []], |
| 200 | RequestMetadata: [self.handle_missing_metadata_events, [chain_state]], |
| 201 | } |
| 202 | |
| 203 | for event in events: |
| 204 | t_event = type(event) |
| 205 | if t_event in event_handler_map: |
| 206 | method, args = event_handler_map[t_event] |
| 207 | method(raiden, event, *args) |
| 208 | elif t_event in UNEVENTFUL_EVENTS: |
| 209 | pass |
| 210 | else: |
| 211 | log.error( |
| 212 | "Unknown event", |
| 213 | event_type=str(t_event), |
| 214 | node=to_checksum_address(raiden.address), |
| 215 | ) |
| 216 | |
| 217 | all_messages: List[MessagesQueue] = [ |
| 218 | MessagesQueue(queue_identifier, messages) |
| 219 | for queue_identifier, messages in message_queues.items() |
| 220 | ] |
| 221 | raiden.transport.send_async(all_messages) |
| 222 | |
| 223 | @staticmethod |
| 224 | def handle_missing_metadata_events( |
nothing calls this directly
no test coverage detected