mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-10 23:20:55 +00:00
WIP: chat example
This commit is contained in:
parent
96edf96e76
commit
9123760191
17
peer/id.py
Normal file
17
peer/id.py
Normal file
@ -0,0 +1,17 @@
|
||||
import base58
|
||||
|
||||
class ID:
|
||||
|
||||
def __init__(self, id_str):
|
||||
self._id_str = id_str
|
||||
|
||||
def pretty(self):
|
||||
return base58.b58encode(self._id_str).decode()
|
||||
|
||||
def __str__(self):
|
||||
pid = self.pretty()
|
||||
if len(pid) <= 10:
|
||||
return "<peer.ID %s>" % pid
|
||||
return "<peer.ID %s*%s>" % (pid[:2], pid[len(pid)-6:])
|
||||
|
||||
__repr__ = __str__
|
||||
Reference in New Issue
Block a user