feat(api): better log for push_tx error
@@ -16,6 +16,7 @@ import struct
from json import JSONDecodeError
from typing import TYPE_CHECKING, Any, Dict, Optional, cast
+from structlog import get_logger
from twisted.web import resource
from twisted.web.http import Request
@@ -32,6 +33,7 @@ if TYPE_CHECKING:
from hathor.manager import HathorManager
settings = HathorSettings()
+logger = get_logger()
ARGS = ['hex_tx']
@@ -46,6 +48,7 @@ class PushTxResource(resource.Resource):
def __init__(self, manager: 'HathorManager', max_output_script_size: Optional[int] = None,
allow_non_standard_script: bool = False) -> None:
+ self.log = logger.new()
# Important to have the manager so we can know the tx_storage
self.manager = manager
self.max_output_script_size: int = (
@@ -112,6 +115,7 @@ class PushTxResource(resource.Resource):
try:
success = self.manager.propagate_tx(tx, fails_silently=False)
except (InvalidNewTransaction, TxValidationError) as e:
+ self.log.info('validation failed', exc_info=True)
success = False
message = str(e)
data = {'success': success, 'message': message}
