'Add rows to the \'rejections\' table for received events which were
rejected
Args:
txn (twisted.enterprise.adbapi.Connection): db connection
events_and_contexts (list[(EventBase, EventContext)]): events
we are persisting
Returns:
list[(EventBase, EventContext)] new list, without the rejected
events.'

def _store_rejected_events_txn(self, txn, events_and_contexts):

    to_remove = set()
    for (event, context) in events_and_contexts:
        if context.rejected:
            self._store_rejections_txn(txn, event.event_id, context.rejected)
            to_remove.add(event)
    return [ec for ec in events_and_contexts if (ec[0] not in to_remove)]
