Skip to content

Instantly share code, notes, and snippets.

@aunyks
Last active May 10, 2022 00:58
  • Star 14 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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()
@strive722
Copy link

Thank you for sharing, I am a beginner in the beginning of the blockchain.

@tharitc
Copy link

tharitc commented Aug 28, 2021

Thank you for sharing, I am a beginner in the beginning of the blockchain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment