Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Make txHash in invoke log message human-readable
Browse files Browse the repository at this point in the history
  • Loading branch information
goldworm committed Nov 11, 2020
1 parent d9fd269 commit bd5da74
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion iconservice/icon_service_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@ def invoke(self,
tx_timer.start()

for index, tx_request in enumerate(tx_requests):
Logger.debug(_TAG, f"INVOKE tx: {tx_request}")
tx_hash: Optional[bytes] = tx_request["params"].get("txHash")
Logger.debug(_TAG, f"INVOKE tx: tx_hash={bytes_to_hex(tx_hash)} {tx_request}")

# Adjust the number of transactions in a block to make sure that
# a leader can broadcast a block candidate to validators in a specific period.
Expand Down
9 changes: 8 additions & 1 deletion iconservice/iconscore/icon_score_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from ..base.block import Block
from ..base.exception import ExceptionCode
from ..icon_constant import DATA_BYTE_ORDER
from ..utils import bytes_to_hex
from ..utils.bloom import BloomFilter

if TYPE_CHECKING:
Expand Down Expand Up @@ -98,7 +99,13 @@ def __init__(
self.traces = None

def __str__(self) -> str:
return '\n'.join([f'{k}: {v}' for k, v in self.__dict__.items()])
def func():
for k, v in self.__dict__.items():
if isinstance(v, bytes):
v = bytes_to_hex(v)
yield f'{k}: {v}'

return '\n'.join(func())

def to_dict(self, casing: Optional[callable] = None) -> dict:
"""
Expand Down

0 comments on commit bd5da74

Please sign in to comment.