Decorator for the check() method on a state-preordering operation.
    Make sure that there are no duplicate preorders anywhere--either in this
    block, or in any previous blocks.

def state_preorder(collision_checker):
    """
    Decorator for the check() method on a state-preordering operation.
    Make sure that there are no duplicate preorders anywhere--either in this
    block, or in any previous blocks.
    """
    def wrap( check ):
        def wrapped_check( state_engine, nameop, block_id, checked_ops ):
            rc = check( state_engine, nameop, block_id, checked_ops )
            if rc:
                # verify no duplicates 
                history_id_key = "preorder_hash"
                rc = state_check_collisions( state_engine, nameop, history_id_key, block_id, checked_ops, collision_checker )
                if rc:
                    log.debug("COLLISION on %s '%s'" % (history_id_key, nameop[history_id_key]))
                    rc = False 
                else:
                    # no collision
                    rc = True

                # sanity check---we need to have the appropriate metadata for this operation
                invariant_tags = state_preorder_invariant_tags()
                for tag in invariant_tags:
                    assert tag in nameop, "BUG: missing invariant tag '%s'" % tag

                # sanity check---all required consensus fields must be present
                for required_field in CONSENSUS_FIELDS_REQUIRED:
                    assert required_field in nameop, 'BUG: missing required consensus field {}'.format(required_field)

            return rc
        return wrapped_check
    return wrap