Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 79d0cd2

Browse files
committed
Include block hash prefix in str(block)
1 parent 96527de commit 79d0cd2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

docs/guides/understanding_the_mining_process.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,4 +385,4 @@ zero value transfer transaction.
385385
... )
386386

387387
>>> chain.mine_block(mix_hash=mix_hash, nonce=nonce)
388-
<ByzantiumBlock(#Block #1)>
388+
<ByzantiumBlock(#Block #1-0x41f6..2913)>

eth/rlp/blocks.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
Type
33
)
44

5+
from eth_utils import (
6+
humanize_hash,
7+
)
8+
59
from eth._utils.datatypes import (
610
Configurable,
711
)
8-
912
from eth.abc import (
1013
BlockAPI,
1114
SignedTransactionAPI,
@@ -29,4 +32,5 @@ def __repr__(self) -> str:
2932
return f'<{self.__class__.__name__}(#{str(self)})>'
3033

3134
def __str__(self) -> str:
32-
return f"Block #{self.number}"
35+
clipped_hash = humanize_hash(self.hash)
36+
return f"Block #{self.number}-0x{clipped_hash}"

0 commit comments

Comments
 (0)