Beispiel #1
0
def getSupplier(ID):
    """
    Return peer's identity if he is in suppliers list.
    """
    if contactsdb.is_supplier(ID):
        return identitycache.FromCache(ID)
    return None
Beispiel #2
0
def isKnown(idurl):
    """
    Return True if this is a known ID.
    """
    if idurl == settings.CentralID():
        return True
    if idurl == settings.MoneyServerID():
        return True
    if idurl == settings.MarketServerID():
        return True
    if contactsdb.is_supplier(idurl):
        return True
    if contactsdb.is_customer(idurl):
        return True
    if contactsdb.is_correspondent(idurl):
        return True
    return False
Beispiel #3
0
def getContact(idurl):
    """
    The Main Method Here - return identity object for given ID or None if not found. 
    Only valid contacts for dhnpackets will be signed by local identity, suppliers, customers
    and eventually dhn central command.
    """
    #    global _RequestFailsDict
    if idurl is None:
        return None
    if idurl == misc.getLocalID():
        return misc.getLocalIdentity()
    if idurl == settings.CentralID():
        return identitycache.FromCache(idurl)
    if idurl == settings.MoneyServerID():
        return identitycache.FromCache(idurl)
    if idurl == settings.MarketServerID():
        return identitycache.FromCache(idurl)
    if contactsdb.is_supplier(idurl):
        return identitycache.FromCache(idurl)
    if contactsdb.is_customer(idurl):
        return identitycache.FromCache(idurl)
    if contactsdb.is_correspondent(idurl):
        return identitycache.FromCache(idurl)
    if identitycache.HasKey(idurl):
        # dhnio.Dprint(2, "contacts.getContact WARNING who is %s ?" % nameurl.GetName(idurl))
        return identitycache.FromCache(idurl)
    if misc.getLocalID() == settings.MarketServerID():
        return None
    dhnio.Dprint(2, "contacts.getContact WARNING %s not found!" % nameurl.GetName(idurl))
    #    if not _RequestFailsDict.has_key(idurl):
    #        _RequestFailsDict[idurl] = 0
    #    _RequestFailsDict[idurl] += 1
    # TODO
    # this is not correct: 
    # need to check if other contacts is fine - if internet is turned off we can get lots fails ...  
    return None
Beispiel #4
0
def IsSupplier(supid):
    """
    Verify that `supid` is included in suppliers list.
    """
    return contactsdb.is_supplier(supid)