Created
August 24, 2018 19:47
-
-
Save wy/e0df9cc085c371f6d34c6117237054f3 to your computer and use it in GitHub Desktop.
Block discrepancy code
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 requests | |
import json | |
known = {} | |
# investigate block 2,623,809 | |
block = 2623809 | |
request_json = "{\r\n \"jsonrpc\": \"2.0\",\r\n \"method\": \"getblockhash\",\r\n \"params\": [2623809],\r\n \"id\": 3\r\n}" | |
request_json_prev = "{\r\n \"jsonrpc\": \"2.0\",\r\n \"method\": \"getblock\",\r\n \"params\": [2623810,1],\r\n \"id\": 3\r\n}" | |
def get_blockhash(addr): | |
try: | |
r = requests.post(addr, data=request_json, timeout=2) | |
jr = r.json() | |
print(addr, jr['result']) | |
except: | |
pass | |
def get_blockhash_prev(addr): | |
try: | |
r = requests.post(addr, data=request_json_prev, timeout=2) | |
jr = r.json() | |
print(addr, jr['result']['previousblockhash']) | |
except: | |
pass | |
def all_in_one(): | |
#from endpoints to results | |
z = requests.get("https://api.happynodes.f27.ventures/redis/endpoints", timeout=10) | |
dynamic_endpoints = json.loads(z.text) | |
print(len(dynamic_endpoints['sites'])) | |
for s in dynamic_endpoints['sites']: | |
port = s['port'] | |
url = s['url'] | |
protocol = s['protocol'] | |
full_addr = protocol + "://" + url + ":" + str(port) | |
get_blockhash_prev(full_addr) | |
all_in_one() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment