Skip to content

Commit f8346b2

Browse files
Narrow example error handling; document datetime semantics
- examples/issue_token.py: wallet sync failures catch RPC/JSON-RPC errors specifically instead of Exception (programming errors stay loud) - indexer/pool.py: document naive-datetime interpretation for block stats
1 parent e5a533d commit f8346b2

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎examples/issue_token.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@
4040
import sys
4141
import time
4242

43+
from mintlayer._jsonrpc import JSONRPCError
4344
from mintlayer.wallet import (
4445
Amount,
4546
IssueTokenParams,
4647
MintParams,
48+
RPCError,
4749
TokenMetadata,
4850
TokenSupply,
4951
)
@@ -99,8 +101,9 @@ def main() -> None:
99101
# ── 2. Sync the wallet ───────────────────────────────────────────────────
100102
try:
101103
wallet.sync_wallet()
102-
except Exception as exc:
103-
# Non-fatal: the daemon may already be syncing.
104+
except (RPCError, JSONRPCError) as exc:
105+
# Non-fatal: the daemon may already be syncing. Deliberately narrow —
106+
# programming errors must not be silenced here.
104107
log.info("sync wallet: %s (continuing)", exc)
105108

106109
# ── 3. Derive a fresh address to act as the token authority ──────────────

‎mintlayer/indexer/pool.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ def get_pool(self, pool_id: str) -> Pool:
1919
return Pool.from_json(self.get(f"/pool/{_seg(pool_id)}"))
2020

2121
def get_pool_block_stats(self, pool_id: str, from_time: datetime, to_time: datetime) -> int:
22-
"""Return the block count produced in the half-open interval [from, to)."""
22+
"""Return the block count produced in the half-open interval [from, to).
23+
24+
Naive datetimes are interpreted in the system's local timezone
25+
(standard ``datetime.timestamp()`` semantics); pass tz-aware
26+
datetimes for unambiguous absolute times.
27+
"""
2328
data = self.get(
2429
f"/pool/{_seg(pool_id)}/block-stats",
2530
{"from": int(from_time.timestamp()), "to": int(to_time.timestamp())},

0 commit comments

Comments
 (0)