Given a name and a value hash (i.e. the zone file hash), return the txid for the value hash.
        Return None if the name doesn't exist, or is revoked, or did not
        receive a NAME_UPDATE since it was last preordered.

def get_name_value_hash_txid( self, name, value_hash ):
        """
        Given a name and a value hash (i.e. the zone file hash), return the txid for the value hash.
        Return None if the name doesn't exist, or is revoked, or did not
        receive a NAME_UPDATE since it was last preordered.
        """
        rec = self.get_name( name )
        if rec is None:
            return None 

        if rec['revoked']:
            return None
        
        # find the txid of the given value hash
        if rec['value_hash'] == value_hash:
            return rec['txid']

        else:
            # search backwards for it 
            hist = rec['history']
            flat_hist = namedb_flatten_history( hist )
            for i in xrange(len(flat_hist)-1, 0, -1):
                delta = flat_hist[i]
                if delta['op'] == NAME_PREORDER:
                    # this name was re-registered. skip
                    return None 

                if delta['value_hash'] == value_hash:
                    # this is the txid that affected it 
                    return delta['txid']

            # not found
            return None