Розмір відео: 1280 X 720853 X 480640 X 360
Показувати елементи керування програвачем
Автоматичне відтворення
Автоповтор
Watch more videos here: ua-cam.com/play/PLWPirh4EWFpHalWFs7mvo4Ui97rkDMaN9.html&si=EpUprtRHPMkvhrug
This tutorial is very interesting! I want to ask some question Where the BC is saved?
@Arnab Sen How can I show the transaction has been recorded ?
is there any wrong in while loop...its showing error
the code please?
import hashlibclass Block: def __init__(self, no, nonce, data, hashcode, prev): self.no=no self.nonce=nonce self.data=data self.hashcode=hash self.prev=prev def getStringVal(): return self.no, self.nonce, self.data, self.hashcode, self.prevclass Blockchain: def __init__(self): self.chain=[] self.prefix="0000" def addNewBlock(self, data): no=len(self.chain) nonce=0 if len(self.chain)==0: prev="0" else: prev=self.chain[-1].hashcode myHash hashlib.sha256(str(data).encode('utf-8')).hexdigest() block=Block(no, nonce, data, myHash, prev) self.chain.append(block) def printBlockchain(self): chainDict={} for no in range(len(self.chain)): chainDict[no]=self.chain[no].getStringVal() print(chainDict) def mineChain(self): brokenLink=self.checkIfBroken if (brokenLink==None): pass else: for block in self.chain[brokenLink.no:]: print("Mining Block:" block.getStringVal()) self.mineBlock(block) def mineBlock(self, block): nonce=0 myHash=hashlib.sha256(str(nonce)+str(block.data)).encode('utf-8').hexdigest() while myHash[0:4]!=self.prefix: myHash=hashlib.sha256(str(nonce)+str(block.data)).encode('utf-8').hexdigest() nonce=nonce+1 else: self.chain[block.no].hashcode=myHash self.chain[block.no].nonce=nonce if (block.no
it displays: ModuleNotFoundError: No module named 'blockchain' !!!
Watch more videos here: ua-cam.com/play/PLWPirh4EWFpHalWFs7mvo4Ui97rkDMaN9.html&si=EpUprtRHPMkvhrug
This tutorial is very interesting! I want to ask some question Where the BC is saved?
@Arnab Sen How can I show the transaction has been recorded ?
is there any wrong in while loop...its showing error
the code please?
import hashlib
class Block:
def __init__(self, no, nonce, data, hashcode, prev):
self.no=no
self.nonce=nonce
self.data=data
self.hashcode=hash
self.prev=prev
def getStringVal():
return self.no, self.nonce, self.data, self.hashcode, self.prev
class Blockchain:
def __init__(self):
self.chain=[]
self.prefix="0000"
def addNewBlock(self, data):
no=len(self.chain)
nonce=0
if len(self.chain)==0:
prev="0"
else:
prev=self.chain[-1].hashcode
myHash hashlib.sha256(str(data).encode('utf-8')).hexdigest()
block=Block(no, nonce, data, myHash, prev)
self.chain.append(block)
def printBlockchain(self):
chainDict={}
for no in range(len(self.chain)):
chainDict[no]=self.chain[no].getStringVal()
print(chainDict)
def mineChain(self):
brokenLink=self.checkIfBroken
if (brokenLink==None):
pass
else:
for block in self.chain[brokenLink.no:]:
print("Mining Block:" block.getStringVal())
self.mineBlock(block)
def mineBlock(self, block):
nonce=0
myHash=hashlib.sha256(str(nonce)+str(block.data)).encode('utf-8').hexdigest()
while myHash[0:4]!=self.prefix:
myHash=hashlib.sha256(str(nonce)+str(block.data)).encode('utf-8').hexdigest()
nonce=nonce+1
else:
self.chain[block.no].hashcode=myHash
self.chain[block.no].nonce=nonce
if (block.no
it displays: ModuleNotFoundError: No module named 'blockchain' !!!