Skip to content

Commit

Permalink
Absolute imports, decode_hex, use as in exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
utzig committed Jul 11, 2016
1 parent c82c4cf commit 30fb951
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions devp2p/peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
import gevent
import operator
from collections import OrderedDict
from protocol import BaseProtocol
from p2p_protocol import P2PProtocol
from service import WiredService
import multiplexer
from muxsession import MultiplexedSession
from .protocol import BaseProtocol
from .p2p_protocol import P2PProtocol
from .service import WiredService
from .multiplexer import MultiplexerError, Packet
from .muxsession import MultiplexedSession
from crypto import ECIESDecryptionError
import slogging
import gevent.socket
import rlpxcipher
from rlp.utils import decode_hex

log = slogging.get_logger('p2p.peer')

Expand Down Expand Up @@ -39,7 +40,7 @@ def __init__(self, peermanager, connection, remote_pubkey=None):
log.debug('peer init', peer=self)

# create multiplexed encrypted session
privkey = self.config['node']['privkey_hex'].decode('hex')
privkey = decode_hex(self.config['node']['privkey_hex'])
hello_packet = P2PProtocol.get_hello_packet(self)
self.mux = MultiplexedSession(privkey, hello_packet, remote_pubkey=remote_pubkey)
self.remote_pubkey = remote_pubkey
Expand Down Expand Up @@ -192,10 +193,10 @@ def protocol_cmd_id_from_packet(self, packet):
raise UnknownCommandError('no protocol for protocol id %s' % packet.protocol_id)

def _handle_packet(self, packet):
assert isinstance(packet, multiplexer.Packet)
assert isinstance(packet, Packet)
try:
protocol, cmd_id = self.protocol_cmd_id_from_packet(packet)
except UnknownCommandError, e:
except UnknownCommandError as e:
log.error('received unknown cmd', error=e, packet=packet)
return
log.debug('recv packet', cmd=protocol.cmd_by_id[
Expand Down Expand Up @@ -268,7 +269,7 @@ def _run_ingress_message(self):
log.debug('rlpx session error', peer=self, error=e)
self.report_error('rlpx session error')
self.stop()
except multiplexer.MultiplexerError as e:
except MultiplexerError as e:
log.debug('multiplexer error', peer=self, error=e)
self.report_error('multiplexer error')
self.stop()
Expand Down

0 comments on commit 30fb951

Please sign in to comment.