Skip to content

Instantly share code, notes, and snippets.

@brucevanhorn2
Forked from aunyks/snakecoin-block.py
Created February 23, 2018 21:28
Show Gist options
  • Save brucevanhorn2/e6b2ac55ea2896eb67b35893b3a8f3a6 to your computer and use it in GitHub Desktop.
Save brucevanhorn2/e6b2ac55ea2896eb67b35893b3a8f3a6 to your computer and use it in GitHub Desktop.
The block structure for SnakeCoin.
import hashlib as hasher
class Block:
def __init__(self, index, timestamp, data, previous_hash):
self.index = index
self.timestamp = timestamp
self.data = data
self.previous_hash = previous_hash
self.hash = self.hash_block()
def hash_block(self):
sha = hasher.sha256()
sha.update(str(self.index) +
str(self.timestamp) +
str(self.data) +
str(self.previous_hash))
return sha.hexdigest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment