block.py 608 B

12345678910111213141516
  1. class Block:
  2. ''' This class represents a tuple of the form (h, e, txs).
  3. Each blocks parent hash h may be computed simply as a hash of the parent block. '''
  4. def __init__(self, h, e, txs):
  5. self.h = h # parent hash
  6. self.e = e # epoch number
  7. self.txs = txs # transactions payload
  8. def __repr__(self):
  9. return "Block=[h={0}, e={1}, txs={2}]".format(self.h, self.e, self.txs)
  10. def __hash__(self):
  11. return hash((self.h, self.e, self.txs)) # python hash is used for demostranation porpuses only.
  12. def __eq__(self, other):
  13. return self.h == other.h and self.e == other.e and self.txs == other.txs