Skip to content

Commit

Permalink
Fix #35
Browse files Browse the repository at this point in the history
  • Loading branch information
jibeee authored and lpascal-ledger committed Jun 30, 2022
1 parent 75bf879 commit a7f821b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ledgerwallet/transport/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def write(self, data: bytes):
raise NotImplementedError

@abstractmethod
def read(self) -> bytes:
def read(self, timeout: int = 0) -> bytes:
raise NotImplementedError

@abstractmethod
def exchange(self, data: bytes) -> bytes:
def exchange(self, data: bytes, timeout: int = 0) -> bytes:
raise NotImplementedError

@abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion ledgerwallet/transport/hid.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def read(self, timeout: int = 1000) -> bytes:

def exchange(self, data: bytes, timeout: int = 1000):
self.write(data)
return self.read(timeout)
return self.read(timeout=timeout)

def close(self):
if self.opened:
Expand Down
4 changes: 2 additions & 2 deletions ledgerwallet/transport/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def write(self, data: bytes):
data_to_send = int.to_bytes(len(data), 4, "big") + data
self.socket.send(data_to_send)

def read(self) -> bytes:
def read(self, timeout: int = 0) -> bytes:
packet_len = int.from_bytes(self.socket.recv(4), "big")
return self.socket.recv(packet_len + 2)

def exchange(self, data: bytes):
def exchange(self, data: bytes, timeout: int = 0):
self.write(data)
return self.read()

Expand Down

0 comments on commit a7f821b

Please sign in to comment.