Skip to content

Instantly share code, notes, and snippets.

@hrobeers
Created July 14, 2017 07:34
Show Gist options
  • Save hrobeers/3de9d6e8d378107fd226185c81539b76 to your computer and use it in GitHub Desktop.
Save hrobeers/3de9d6e8d378107fd226185c81539b76 to your computer and use it in GitHub Desktop.
Prints the percentage of version 2 blocks in last 100 blocks
#! /usr/bin/python3
from peercoin_rpc import Client
number_of_blocks = 100
ppcnode = Client(testnet=True, username="testnet", password="testnetpw", ip="localhost", port=8888)
last_block_hash = ppcnode.getblockhash(ppcnode.getblockcount())
block_versions = []
for i in range(0, number_of_blocks):
block = ppcnode.getblock(last_block_hash)
last_block_hash = block['previousblockhash']
block_versions.append(block['version'])
fork_perc = block_versions.count(2) * 100 / number_of_blocks
print(fork_perc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment