Last active
August 3, 2018 15:46
-
-
Save Mambix/900ec18e8f119d000d003c1675537db6 to your computer and use it in GitHub Desktop.
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
.idea |
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
import requests | |
import json | |
import time | |
def rpc(command, parameters=[]): | |
options = { | |
"id": time.time(), | |
"jsonrpc": "2.0", | |
"method": command, | |
"params": parameters | |
} | |
res = requests.post('http://192.168.0.221:8545', json=options) | |
data = json.loads(res.text) | |
if 'result' in data: | |
return data['result'] | |
return None | |
data = rpc('eth_syncing') | |
hb = int(data['highestBlock'], 16) | |
cb = int(data['currentBlock'], 16) | |
sb = int(data['startingBlock'], 16) | |
ks = int(data['knownStates'], 16) | |
ps = int(data['pulledStates'], 16) | |
print('Information:') | |
print('\tBlockNumber: {}'.format(int(rpc('eth_blockNumber'), 16))) | |
print('\tHighest Block: {}'.format(hb)) | |
print('\tCurrent Block: {}'.format(cb)) | |
print('\tStarting Block: {}'.format(sb)) | |
print('\tKnnown States: {}'.format(ks)) | |
print('\tPulled States: {}'.format(ps)) | |
print('') | |
print('Remaining:') | |
print('\t {} Blocks: {} %'.format(hb-cb, (cb/hb) * 100.0)) | |
print('\t {} States: {} %'.format(ks-ps, (ps/ks) * 100.0)) | |
print('peerCount: {}'.format(int(rpc('net_peerCount'), 16))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment