Created
June 2, 2016 22:12
-
-
Save mDuo13/d60522735ab36d52de0d187edd0006fb to your computer and use it in GitHub Desktop.
search for EnableAmendment (Python)
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 txsplain | |
# You need to modify txsplain's lookup_ledger function for this code to work. | |
# The code as published doesn't have expand=True. (It's a trivial change though.) | |
# | |
# Also This script also doesn't do any error handling (e.g. if one side of your | |
# search goes beyond the current ledger, it'll just die) | |
def search_ledger(ledger_index, tx_type): | |
ledger = txsplain.lookup_ledger(ledger_index=ledger_index, expand=True) | |
for tx in ledger["transactions"]: | |
if tx["TransactionType"] == tx_type: | |
return tx["hash"] | |
return False | |
ledger_index_start = 21225285 | |
offset = 1 | |
while 1: | |
li = ledger_index_start + offset | |
print("Searching ledger", li) | |
tx_hash = search_ledger(li, "EnableAmendment") | |
if tx_hash: | |
print("Found in ledger %d: hash %s" % (li, tx_hash)) | |
break | |
li = ledger_index_start - offset | |
print("Searching ledger", li) | |
tx_hash = search_ledger(li, "EnableAmendment") | |
if tx_hash: | |
print("Found in ledger %d: hash %s" % (li, tx_hash)) | |
break | |
offset += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment