Check if the message exists in queue with ID `queueid` and exclude if found.
(
message_queue: List[SendMessageEvent],
state_change: Union[ReceiveDelivered, ReceiveProcessed, ReceiveWithdrawConfirmation],
)
| 450 | |
| 451 | |
| 452 | def inplace_delete_message( |
| 453 | message_queue: List[SendMessageEvent], |
| 454 | state_change: Union[ReceiveDelivered, ReceiveProcessed, ReceiveWithdrawConfirmation], |
| 455 | ) -> None: |
| 456 | """Check if the message exists in queue with ID `queueid` and exclude if found.""" |
| 457 | for message in list(message_queue): |
| 458 | # A withdraw request is only confirmed by a withdraw confirmation. |
| 459 | # This is done because Processed is not an indicator that the partner has |
| 460 | # processed and **accepted** our withdraw request. Receiving |
| 461 | # `Processed` here would cause the withdraw request to be removed |
| 462 | # from the queue although the confirmation may have not been sent. |
| 463 | # This is avoided by waiting for the confirmation before removing |
| 464 | # the withdraw request. |
| 465 | if isinstance(message, SendWithdrawRequest): |
| 466 | if not isinstance(state_change, ReceiveWithdrawConfirmation): |
| 467 | continue |
| 468 | |
| 469 | message_found = ( |
| 470 | message.message_identifier == state_change.message_identifier |
| 471 | and message.recipient == state_change.sender |
| 472 | ) |
| 473 | if message_found: |
| 474 | message_queue.remove(message) |
| 475 | |
| 476 | |
| 477 | def handle_block(chain_state: ChainState, state_change: Block) -> TransitionResult[ChainState]: |
no test coverage detected