We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c57fb9b + a9f1af4 commit 968d831Copy full SHA for 968d831
multiaddr/multiaddr.py
@@ -170,6 +170,9 @@ def __str__(self):
170
def __repr__(self):
171
return "<Multiaddr %s>" % str(self)
172
173
+ def __hash__(self):
174
+ return self._bytes.__hash__()
175
+
176
def to_bytes(self):
177
"""Returns the byte array representation of this Multiaddr."""
178
return self._bytes
tests/test_multiaddr.py
@@ -355,3 +355,9 @@ def test_zone():
355
356
maddr_from_bytes = Multiaddr(ip6_bytes)
357
assert str(maddr_from_bytes) == ip6_string
358
359
360
+def test_hash():
361
+ addr_bytes = Multiaddr("/ip4/127.0.0.1/udp/1234").to_bytes()
362
363
+ assert hash(Multiaddr(addr_bytes)) == hash(addr_bytes)
0 commit comments