Last active
March 8, 2024 18:49
-
-
Save aunyks/2aae6d164ba7abb1af8017c50af321b3 to your computer and use it in GitHub Desktop.
The block structure for SnakeCoin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
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
Thank you for sharing, I am a beginner in the beginning of the blockchain.