Esempio n. 1
0
def getAccountsRecent(count):
    count = min(10, int(count))
    cached_key = '/accounts/recent/' + str(count)
    cached = cache.get_cache_entry(cached_key)
    if cached != None:
        accounts = cached
    else:
        accounts = node_rpc_helper.getAccountsRecent(count)
        cache.add_cache_entry(cached_key, accounts, 15)
    setHeaders()
    return accounts
Esempio n. 2
0
def getFrontierCount():
    count = ''
    try:
        cached = cache.get_cache_entry('frontiers/count')
        if cached != None:
            count = cached
        else:
            count = node_rpc_helper.getFrontierCount()
            cache.add_cache_entry('frontiers/count', count)
    except:
        count = 'ERROR'
    setHeaders()
    return count
Esempio n. 3
0
def getBlockCount():
    count = ''
    try:
        cached = cache.get_cache_entry('blocks/count')
        if cached != None:
            #print("Found in cache", cached)
            count = cached
        else:
            count = node_rpc_helper.getBlockCount()
            cache.add_cache_entry('blocks/count', count, 60)
            #print("Put in cache", count)
    except:
        count = 'ERROR'
    setHeaders()
    return count
Esempio n. 4
0
def getPeerCount():
    count = '0'
    try:
        cached = cache.get_cache_entry('peers/count')
        if cached != None:
            count = cached
        else:
            peers = node_rpc_helper.getPeers()
            #print(peers)
            #print(type(peers))
            if ((type(peers) is str) and peers == ''):
                # empty peer list, valid
                count = '0'
            else:
                if (type(peers) is not dict) and (type(peers) is not list):
                    count = 0
                else:
                    count = str(len(peers))
            cache.add_cache_entry('peers/count', count, 60)
    except:
        count = 'ERROR'
    setHeaders()
    return count