Moved missingObjects dict from state to network.objectracker
This commit is contained in:
parent
b2af007280
commit
38318150bd
|
@ -1,6 +1,5 @@
|
||||||
import base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
import random
|
|
||||||
import socket
|
import socket
|
||||||
import struct
|
import struct
|
||||||
import time
|
import time
|
||||||
|
@ -17,7 +16,8 @@ from network.bmobject import BMObject, BMObjectInsufficientPOWError, BMObjectInv
|
||||||
import network.connectionpool
|
import network.connectionpool
|
||||||
from network.node import Node
|
from network.node import Node
|
||||||
from network.objectracker import ObjectTracker
|
from network.objectracker import ObjectTracker
|
||||||
from network.proxy import Proxy, ProxyError, GeneralProxyError
|
from network.proxy import ProxyError
|
||||||
|
from objectracker import missingObjects
|
||||||
|
|
||||||
import addresses
|
import addresses
|
||||||
from queues import objectProcessorQueue, portCheckerQueue, invQueue, addrQueue
|
from queues import objectProcessorQueue, portCheckerQueue, invQueue, addrQueue
|
||||||
|
@ -359,7 +359,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
BMProto.stopDownloadingObject(self.object.inventoryHash, True)
|
BMProto.stopDownloadingObject(self.object.inventoryHash, True)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
del state.missingObjects[self.object.inventoryHash]
|
del missingObjects[self.object.inventoryHash]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -559,7 +559,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
del state.missingObjects[hashId]
|
del missingObjects[hashId]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import random
|
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import addresses
|
import addresses
|
||||||
|
import helper_random
|
||||||
|
import protocol
|
||||||
from dandelion import Dandelion
|
from dandelion import Dandelion
|
||||||
from debug import logger
|
from debug import logger
|
||||||
from helper_threading import StoppableThread
|
from helper_threading import StoppableThread
|
||||||
from inventory import Inventory
|
from inventory import Inventory
|
||||||
from network.connectionpool import BMConnectionPool
|
from network.connectionpool import BMConnectionPool
|
||||||
import protocol
|
from objectracker import missingObjects
|
||||||
from state import missingObjects
|
|
||||||
import helper_random
|
|
||||||
|
|
||||||
class DownloadThread(threading.Thread, StoppableThread):
|
class DownloadThread(threading.Thread, StoppableThread):
|
||||||
minPending = 200
|
minPending = 200
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import time
|
import time
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
|
|
||||||
from inventory import Inventory
|
|
||||||
import network.connectionpool
|
import network.connectionpool
|
||||||
from network.dandelion import Dandelion
|
from network.dandelion import Dandelion
|
||||||
from randomtrackingdict import RandomTrackingDict
|
from randomtrackingdict import RandomTrackingDict
|
||||||
from state import missingObjects
|
|
||||||
|
|
||||||
haveBloom = False
|
haveBloom = False
|
||||||
|
|
||||||
|
@ -24,6 +22,10 @@ except ImportError:
|
||||||
# it isn't actually implemented yet so no point in turning it on
|
# it isn't actually implemented yet so no point in turning it on
|
||||||
haveBloom = False
|
haveBloom = False
|
||||||
|
|
||||||
|
# tracking pending downloads globally, for stats
|
||||||
|
missingObjects = {}
|
||||||
|
|
||||||
|
|
||||||
class ObjectTracker(object):
|
class ObjectTracker(object):
|
||||||
invCleanPeriod = 300
|
invCleanPeriod = 300
|
||||||
invInitialCapacity = 50000
|
invInitialCapacity = 50000
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from network.connectionpool import BMConnectionPool
|
|
||||||
import asyncore_pollchoose as asyncore
|
import asyncore_pollchoose as asyncore
|
||||||
from state import missingObjects
|
from network.connectionpool import BMConnectionPool
|
||||||
|
from objectracker import missingObjects
|
||||||
|
|
||||||
lastReceivedTimestamp = time.time()
|
lastReceivedTimestamp = time.time()
|
||||||
lastReceivedBytes = 0
|
lastReceivedBytes = 0
|
||||||
|
|
|
@ -51,9 +51,6 @@ trustedPeer = None
|
||||||
|
|
||||||
discoveredPeers = {}
|
discoveredPeers = {}
|
||||||
|
|
||||||
# tracking pending downloads globally, for stats
|
|
||||||
missingObjects = {}
|
|
||||||
|
|
||||||
Peer = collections.namedtuple('Peer', ['host', 'port'])
|
Peer = collections.namedtuple('Peer', ['host', 'port'])
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user