From 78602c7086cd94a67b69e2e34097e5db5c330f39 Mon Sep 17 00:00:00 2001 From: Inso <insomniak.fr@gmail.com> Date: Sat, 14 Mar 2015 15:48:14 +0100 Subject: [PATCH] Fixed Blocks caching --- README.md | 2 +- src/cutecoin/core/community.py | 15 ++++++++------- src/cutecoin/core/net/network.py | 5 +---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 60c30edb..beb816a7 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Qt Client for [Ucoin](http://www.ucoin.io) project. * The executable is generated in "build" folder, named "cutecoin" ### How to download latest release - * Go to the [current release](https://github.com/ucoin-io/cutecoin/releases/tag/0.8.2) + * Go to the [current release](https://github.com/ucoin-io/cutecoin/releases/tag/0.9.0) * Download the package corresponding to your operating system * Unzip and start "cutecoin" :) * Join our beta community by contacting us on ucoin forums : forum.ucoin.io diff --git a/src/cutecoin/core/community.py b/src/cutecoin/core/community.py index 171fc813..93451ef8 100644 --- a/src/cutecoin/core/community.py +++ b/src/cutecoin/core/community.py @@ -17,8 +17,7 @@ from requests.exceptions import RequestException class Cache(): - _saved_requests = [hash(bma.blockchain.Block), - hash(bma.wot.Lookup)] + _saved_requests = [str(bma.blockchain.Block)] def __init__(self, community): ''' @@ -48,6 +47,8 @@ class Cache(): :return: The cache as a dict in json format ''' + #TODO: Change the requests caching because hashed keys are different + #from a cutecoin run to another data = {k: self.data[k] for k in self.data.keys() if k[0] in Cache._saved_requests} entries = [] @@ -75,11 +76,11 @@ class Cache(): :param req_args: The arguments passed to the request constructor :param get_args: The arguments passed to the requests __get__ method ''' - cache_key = (hash(request), - hash(tuple(frozenset(sorted(req_args.keys())))), - hash(tuple(frozenset(sorted(req_args.items())))), - hash(tuple(frozenset(sorted(get_args.keys())))), - hash(tuple(frozenset(sorted(get_args.items()))))) + cache_key = (str(request), + str(tuple(frozenset(sorted(req_args.keys())))), + str(tuple(frozenset(sorted(req_args.items())))), + str(tuple(frozenset(sorted(get_args.keys())))), + str(tuple(frozenset(sorted(get_args.items()))))) if cache_key not in self.data.keys(): result = self.community.request(request, req_args, get_args, diff --git a/src/cutecoin/core/net/network.py b/src/cutecoin/core/net/network.py index bab907d6..26b1948d 100644 --- a/src/cutecoin/core/net/network.py +++ b/src/cutecoin/core/net/network.py @@ -3,10 +3,6 @@ Created on 24 févr. 2015 @author: inso ''' - -from ucoinpy.documents.peer import Peer, BMAEndpoint -from ucoinpy.api import bma - from .node import Node import logging @@ -166,6 +162,7 @@ class Network(QObject): node.check_sync(block_max) #TODO: Offline nodes for too long have to be removed + #TODO: Corrupted nodes should maybe be removed faster ? logging.debug("Nodes found : {0}".format(nodes)) -- GitLab