code: def handle_block(
          mediator_state: MediatorTransferState,
          state_change: Block,
          channelidentifiers_to_channels: ChannelMap,
          pseudo_random_generator: random.Random,
  ) -> TransitionResult[MediatorTransferState]:
      
      expired_locks_events = events_to_remove_expired_locks(
          mediator_state,
          channelidentifiers_to_channels,
          state_change.block_number,
          pseudo_random_generator,
      )
  
      secret_reveal_events = events_for_onchain_secretreveal_if_dangerzone(
          channelmap=channelidentifiers_to_channels,
          secrethash=mediator_state.secrethash,
          transfers_pair=mediator_state.transfers_pair,
          block_number=state_change.block_number,
          block_hash=state_change.block_hash,
      )
  
      unlock_fail_events = events_for_expired_pairs(
          channelidentifiers_to_channels=channelidentifiers_to_channels,
          transfers_pair=mediator_state.transfers_pair,
          waiting_transfer=mediator_state.waiting_transfer,
          block_number=state_change.block_number,
      )
  
      iteration = TransitionResult(
          mediator_state,
          unlock_fail_events + secret_reveal_events + expired_locks_events,
      )
  
      return iteration
docs: After Raiden learns about a new block this function must be called to
      handle expiration of the hash time locks.
      Args:
          state: The current state.
      Return:
          TransitionResult: The resulting iteration