小编给大家分享一下python如何实现交易记录整合交易类,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!
这里继续整合交易类。
import datetime #交易类,后期需要整合公钥,私钥 class Transaction: #payer 付款方,receiver收款方 def __init__(self,payer,receiver,money): self.payer = payer self.receiver = receiver self.money = money self.timestamp = datetime.datetime.now() #交易时间 def __repr__(self): return str(self.payer)+" pay "+str(self.receiver)+" "+str(self.money)+" "+str(self.timestamp) if __name__=="__main__": t = Transaction("yicheng","ddd",100) print(t)
测试模块:
if __name__=="__main__": t1 = Transaction("yicheng", "ddd1", 100) t2 = Transaction("yicheng", "ddd2", 200) t3 = Transaction("yicheng", "ddd3", 300) m1 = DaDaMessage(t1) m2 = DaDaMessage(t2) m3 = DaDaMessage(t3) try: m1.seal() m2.link(m1) m2.seal() m3.link(m2) m3.seal() #m1.hash = "0xaaaajjjjj" #m1.data = "I don't love " m1.validate() m2.validate() m3.validate() print(m1) print(m2) print(m3) except InvalidateMessage as e: print(e)
查看打印结果:
看完了这篇文章,相信你对“python如何实现交易记录整合交易类”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。