Created
November 19, 2017 22:13
-
-
Save pat36/60001886e9387eb7117be1efe276e0d8 to your computer and use it in GitHub Desktop.
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 ipfsapi | |
import json | |
ipfs = ipfsapi.connect() | |
# JSON: | |
# { "data" : "something...", "previousBlock" : "ipfs hash to previous block"} | |
# genesisHash is "Qm00000000000000000000000000000000000000000000" | |
# when previousBlock == genesisHash then we reached the first block | |
genesisHash = "Qm00000000000000000000000000000000000000000000" | |
previousHash = "0" | |
hash = "QmXtdjRXaXQaWmzbDNJmLNURLCGSVMnPcPdXoDKzbqSnBb" | |
ipfs.cat(hash) | |
while previousHash != genesisHash: | |
obj = json.loads(ipfs.cat(hash)) | |
previousHash = hash = obj['previousBlock'] | |
print(obj) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment