Пример #1
0
while True:
    # connect to node and get current mem pool size
    try:
        mempoolInfo = rpc_connection.getmempoolinfo()
    except (socket.error, httplib.CannotSendRequest):
        printMsg("getmempoolinfo http error", COLOR_RED)
        time.sleep(2)
        continue
    numTx = mempoolInfo['size']
    memBytes = mempoolInfo['bytes']

    # load recent block info from file created by blocks.py
    if not os.path.isfile(blockFile):
        printMsg("No block history file, loading best block...", COLOR_RED)
        bestHash = rpc_connection.getbestblockhash()
        os.system("python " + rootdir + "/block.py " + str(bestHash))
    f = open(blockFile, 'r')
    d = f.read()
    blockData = json.loads(d)
    f.close()

    # load peers info from file
    if not os.path.isfile(peerFile):
        peers.refreshPeers()
    p = open(peerFile, 'r')
    pd = p.read()
    peerData = json.loads(pd)
    p.close()

    # check for a new Tx file, load, then delete it
Пример #2
0
while True:		
	# connect to node and get current mem pool size
	try:
		mempoolInfo = rpc_connection.getmempoolinfo()
	except (socket.error, httplib.CannotSendRequest):
		printMsg("getmempoolinfo http error", COLOR_RED)
		time.sleep(2)
		continue	
	numTx = mempoolInfo['size']
	memBytes = mempoolInfo['bytes']
	
	# load recent block info from file created by blocks.py
	if not os.path.isfile(blockFile):
		printMsg("No block history file, loading best block...", COLOR_RED)
		bestHash = rpc_connection.getbestblockhash()
		os.system("python block.py " + str(bestHash))
	f = open(blockFile,'r')
	d = f.read()
	try:
		blockData = json.loads(d)
	except ValueError:
		eout = open("~/pybits/ERR.txt", "w")
		eout.write(d)
		eout.close()
		cleanup()
		print "VALUE ERROR"
		print d
		exit()
	
	f.close()