remove useless code

This commit is contained in:
lakshyacis 2020-01-10 19:52:17 +05:30
parent eb98abbabf
commit 882aa9d970
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB
5 changed files with 1 additions and 27 deletions

View File

@ -105,20 +105,11 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
count += 1
if self.command == 'verack'.encode():
addr_verack += 1
# print('the addr_verack count are -{}'.format(addr_verack))
if self.command == 'version'.encode():
addr_version += 1
# print('the addr_version count are -{}'.format(addr_version))
if self.command == 'addr'.encode():
addr_count += 1
# print('the addr_count count are -{}'.format(addr_count))
if self.magic != 0xE9BEB4D9:
# skip 1 byte in order to sync
# in the advancedispatched and length commend's
# escape the 1 length
self.set_state("bm_header", length=1)
self.bm_proto_reset()
logger.debug('Bad magic')
@ -186,7 +177,6 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
self.set_state("close")
return False
if retval:
# print('if retval is true and inside the if ')
self.set_state("bm_header", length=self.payloadLength)
self.bm_proto_reset()
# else assume the command requires a different state to follow
@ -451,7 +441,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
if self.object.inventoryHash in Inventory() and Dandelion().hasHash(self.object.inventoryHash):
Dandelion().removeHash(self.object.inventoryHash, "cycle detection")
[self.object.inventoryHash] = (
Inventory()[self.object.inventoryHash] = (
self.object.objectType, self.object.streamNumber,
memoryview(self.payload[objectOffset:]), self.object.expiresTime,
memoryview(self.object.tag)
@ -539,7 +529,6 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
return False
def bm_command_version(self):
# print('inside the bmproto ')
"""
Incoming version.
Parse and log, remember important things, like streams, bitfields, etc.

View File

@ -195,7 +195,6 @@ class BMConnectionPool(object):
port = int(BMConfigParser().safeGet("bitmessagesettings", "port"))
# correct port even if it changed
ls = TCPServer(host=bind, port=port)
print('inside the startListening method')
self.listeningSockets[ls.destination] = ls
def startUDPSocket(self, bind=None):

View File

@ -150,7 +150,6 @@ class TCPConnection(BMProto, TLSDispatcher):
))
self.antiIntersectionDelay(True)
self.fullyEstablished = True
# print('inside the set_connection_fully_established in tcp file')
if self.isOutbound:
knownnodes.increaseRating(self.destination)
Dandelion().maybeAddStem(self)
@ -378,7 +377,6 @@ class TCPServer(AdvancedDispatcher):
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.set_reuse_addr()
for attempt in range(50):
print('inside the attempt of line 371')
try:
if attempt > 0:
logger.warning('Failed to bind on port %s', port)

View File

@ -68,7 +68,6 @@ class TLSDispatcher(AdvancedDispatcher):
self.isSSL = False
def state_tls_init(self):
# print()
"""Prepare sockets for TLS handshake"""
# pylint: disable=attribute-defined-outside-init
self.isSSL = True
@ -95,9 +94,7 @@ class TLSDispatcher(AdvancedDispatcher):
ciphers=self.ciphers, do_handshake_on_connect=False)
self.sslSocket.setblocking(0)
self.want_read = self.want_write = True
# print('before tls file python 98 state are :- {}'.format(self.state))
self.set_state("tls_handshake")
# print('after tls file python 100 state are :- {}'.format(self.state))
return False
# if hasattr(self.socket, "context"):
# self.socket.context.set_ecdh_curve("secp256k1")
@ -186,23 +183,18 @@ class TLSDispatcher(AdvancedDispatcher):
return
def tls_handshake(self):
# print('inside the tls_handshake')
"""Perform TLS handshake and handle its stages"""
# wait for flush
if self.write_buf:
return False
# Perform the handshake.
try:
# print "handshaking (internal)"
self.sslSocket.do_handshake()
except ssl.SSLError as err:
# print "%s:%i: handshake fail" % (self.destination.host, self.destination.port)
self.want_read = self.want_write = False
if err.args[0] == ssl.SSL_ERROR_WANT_READ:
# print "want read"
self.want_read = True
if err.args[0] == ssl.SSL_ERROR_WANT_WRITE:
# print "want write"
self.want_write = True
if not (self.want_write or self.want_read):
raise

View File

@ -65,19 +65,15 @@ class UDPSocket(BMProto): # pylint: disable=too-many-instance-attributes
# only addr (peer discovery), error and object are implemented
def bm_command_getdata(self):
# return BMProto.bm_command_getdata(self)
return True
def bm_command_inv(self):
# return BMProto.bm_command_inv(self)
return True
def bm_command_addr(self):
addresses = self._decode_addr()
# only allow peer discovery from private IPs in order to avoid
# attacks from random IPs on the internet
# if not self.local:
# return True
self.local = True
remoteport = False
for seenTime, stream, services, ip, port in addresses: