Created
October 9, 2017 09:43
-
-
Save laurentsenta/48da3faa338fcb411c69e0cbbd1db6ee to your computer and use it in GitHub Desktop.
SingularGarden - How to implement a Blockchain - Add
This file contains hidden or 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
# https://github.com/singulargarden/ouroboros/blob/v0.1/ouroboros/blockchain/__init__.py | |
def add(root_path, proposed_block_hash, payload): | |
""" | |
Make sure we agree on the proposed hash add the block to our chain. | |
Use this when a block comes from an external source. | |
""" | |
new_descr, block = prepare_block(root_path, payload) | |
# Identical to append but we verify the hash! | |
if block.hash != proposed_block_hash: | |
raise HashDoNotMatchException() | |
store_new_block(root_path, new_descr, block) | |
return block.hash | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment