问题描述
我正在尝试将基本的区块链实现与 Manet 网络中的节点连接起来。我正在使用 ns3 的“manet-routing-compare.cc”。老实说,我不知道如何实现它。 这是迄今为止我用 Python 编写的区块链代码:
class Block:
blockNo = 0
next = None
hash = None
nonce = 0
previous_hash = 0x0
timestamp = datetime.datetime.now()
def __init__(self,data):
self.data = data
def hash(self):
h = hashlib.sha256()
h.update(
str(self.nonce).encode('utf-8') +
str(self.data).encode('utf-8') +
str(self.previous_hash).encode('utf-8') +
str(self.timestamp).encode('utf-8') +
str(self.blockNo).encode('utf-8')
)
return h.hexdigest()
def __str__(self):
return "Block Hash: " + str(self.hash()) + "\nBlockNo: " + str(self.blockNo) + "\nHashes: " + str(self.nonce) + "\n"
如果有人可以帮助我将此区块链用于 ns3 manet 模拟,我将不胜感激。感谢您提供可能的答案。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)