我正在尝试将基本区块链实现与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模拟中,我将非常感激。谢谢你可能的答案
目前没有回答
相关问题 更多 >
编程相关推荐