Trying to enable streams 2 and 3 with minimal changes
This commit is contained in:
parent
ebdcc363b1
commit
920b5dc25b
|
@ -249,7 +249,8 @@ class Main(object):
|
|||
# start network components if networking is enabled
|
||||
if state.enableNetwork:
|
||||
start_proxyconfig()
|
||||
BMConnectionPool().connectToStream(1)
|
||||
BMConnectionPool().connectToStream(
|
||||
1 if not state.enableObjProc else None)
|
||||
asyncoreThread = BMNetworkThread()
|
||||
asyncoreThread.daemon = True
|
||||
asyncoreThread.start()
|
||||
|
@ -279,8 +280,8 @@ class Main(object):
|
|||
upnpThread = upnp.uPnPThread()
|
||||
upnpThread.start()
|
||||
else:
|
||||
# Populate with hardcoded value (same as connectToStream above)
|
||||
state.streamsInWhichIAmParticipating.append(1)
|
||||
# Populate with hardcoded value just in case
|
||||
state.streamsInWhichIAmParticipating.add(1)
|
||||
|
||||
if not daemon and state.enableGUI:
|
||||
if state.curses:
|
||||
|
|
|
@ -55,7 +55,7 @@ class BMConnectionPool(object):
|
|||
self.inboundConnections = {}
|
||||
self.listeningSockets = {}
|
||||
self.udpSockets = {}
|
||||
self.streams = []
|
||||
self.streams = set()
|
||||
self._lastSpawned = 0
|
||||
self._spawnWait = 2
|
||||
self._bootstrapped = False
|
||||
|
@ -87,10 +87,18 @@ class BMConnectionPool(object):
|
|||
return [
|
||||
x for x in self.connections() if x.fullyEstablished]
|
||||
|
||||
def connectToStream(self, streamNumber):
|
||||
"""Connect to a bitmessage stream"""
|
||||
self.streams.append(streamNumber)
|
||||
state.streamsInWhichIAmParticipating.append(streamNumber)
|
||||
def connectToStream(self, streamNumber=None):
|
||||
"""
|
||||
Connect to the *streamNumber* bitmessage stream if given;
|
||||
otherwice connect to all streams listed in
|
||||
`state.streamsInWhichIAmParticipating`
|
||||
"""
|
||||
if streamNumber:
|
||||
self.streams.add(streamNumber)
|
||||
state.streamsInWhichIAmParticipating.add(streamNumber)
|
||||
else:
|
||||
for streamNumber in state.streamsInWhichIAmParticipating:
|
||||
self.streams.add(streamNumber)
|
||||
|
||||
def getConnectionByAddr(self, addr):
|
||||
"""
|
||||
|
@ -292,8 +300,8 @@ class BMConnectionPool(object):
|
|||
state.maximumNumberOfHalfOpenConnections - pending):
|
||||
try:
|
||||
chosen = self.trustedPeer or chooseConnection(
|
||||
helper_random.randomchoice(self.streams))
|
||||
except ValueError:
|
||||
helper_random.randomchoice(list(self.streams)))
|
||||
except (ValueError, IndexError):
|
||||
continue
|
||||
if chosen in self.outboundConnections:
|
||||
continue
|
||||
|
|
|
@ -173,8 +173,9 @@ def readKnownNodes():
|
|||
onionport = config.safeGetInt('bitmessagesettings', 'onionport')
|
||||
if onionport:
|
||||
self_peer = Peer(onionhostname, onionport)
|
||||
addKnownNode(1, self_peer, is_self=True)
|
||||
state.ownAddresses[self_peer] = True
|
||||
for stream in state.streamsInWhichIAmParticipating:
|
||||
addKnownNode(stream, self_peer, is_self=True)
|
||||
|
||||
|
||||
def increaseRating(peer):
|
||||
|
|
|
@ -122,6 +122,7 @@ def reloadMyAddressHashes():
|
|||
hasEnabledKeys = True
|
||||
# status
|
||||
addressVersionNumber, streamNumber, hashobj = decodeAddress(addressInKeysFile)[1:]
|
||||
state.streamsInWhichIAmParticipating.add(streamNumber)
|
||||
if addressVersionNumber in (2, 3, 4):
|
||||
# Returns a simple 32 bytes of information encoded
|
||||
# in 64 Hex characters, or null if there was an error.
|
||||
|
@ -160,6 +161,7 @@ def reloadBroadcastSendersForWhichImWatching():
|
|||
address, = row
|
||||
# status
|
||||
addressVersionNumber, streamNumber, hashobj = decodeAddress(address)[1:]
|
||||
state.streamsInWhichIAmParticipating.add(streamNumber)
|
||||
if addressVersionNumber == 2:
|
||||
broadcastSendersForWhichImWatching[hashobj] = 0
|
||||
# Now, for all addresses, even version 2 addresses,
|
||||
|
|
|
@ -3,7 +3,7 @@ Global runtime variables.
|
|||
"""
|
||||
|
||||
neededPubkeys = {}
|
||||
streamsInWhichIAmParticipating = []
|
||||
streamsInWhichIAmParticipating = set()
|
||||
|
||||
extPort = None
|
||||
"""For UPnP"""
|
||||
|
|
Reference in New Issue
Block a user