Blockchain - Writing simulation code run the simulation

Поділитися
Вставка
  • Опубліковано 13 гру 2024

КОМЕНТАРІ • 8

  • @TutorialsPoint_
    @TutorialsPoint_  9 місяців тому

    Watch more videos here: ua-cam.com/play/PLWPirh4EWFpHalWFs7mvo4Ui97rkDMaN9.html&si=EpUprtRHPMkvhrug

  • @aristidengaboyindekwe1554
    @aristidengaboyindekwe1554 6 років тому

    This tutorial is very interesting! I want to ask some question Where the BC is saved?

    • @msadekmarwa5934
      @msadekmarwa5934 3 роки тому

      @Arnab Sen How can I show the transaction has been recorded ?

  • @manojkumarts1153
    @manojkumarts1153 5 років тому +1

    is there any wrong in while loop...its showing error

  • @msadekmarwa5934
    @msadekmarwa5934 3 роки тому +1

    the code please?

    • @huzaifaabedeen7119
      @huzaifaabedeen7119 3 роки тому +1

      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

  • @msadekmarwa5934
    @msadekmarwa5934 3 роки тому

    it displays: ModuleNotFoundError: No module named 'blockchain' !!!