コード例 #1
0
ファイル: contacts.py プロジェクト: vesellov/datahaven
def getCorrespondent(ID):
    """
    Return peer's identity if he is in correspondents list or this is one of DHN servers.
    """
    if contactsdb.is_correspondent(ID):
        return identitycache.FromCache(ID)
    if ID in [settings.CentralID(), settings.MoneyServerID(), settings.MarketServerID()]:
        return identitycache.FromCache(ID) 
    return ''
コード例 #2
0
ファイル: contacts.py プロジェクト: vesellov/datahaven
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
コード例 #3
0
ファイル: contacts.py プロジェクト: vesellov/datahaven
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
コード例 #4
0
ファイル: contacts.py プロジェクト: vesellov/datahaven
def IsCorrespondent(idurl):
    """
    Verify that `idurl` is included in correspondents list.
    """
    return contactsdb.is_correspondent(idurl)