dash/src/robo.py

45 lines
1.7 KiB
Python
Raw Normal View History

2014-04-08 18:08:05 +02:00
import sys
from subprocess import call, check_output
from time import sleep
from random import random, randint
import json
address_current = 0
sent = 0
restart_daemon = 0
last_block = 0
while True:
amount = str(round(random()*10, 1))
2014-04-11 20:10:10 +02:00
obj2 = json.loads(check_output(["./darkcoind", "-datadir=datadir2", "getinfo"]).strip())
obj = json.loads(check_output(["./darkcoind", "-datadir=datadir2", "getpoolinfo"]).strip())
2014-04-08 18:08:05 +02:00
print obj
2014-04-12 17:02:31 +02:00
print obj2['blocks'], obj['connected_to_masternode'], obj['connected_to_masternode'] == obj['current_masternode']
2014-04-08 18:08:05 +02:00
if last_block != obj2['blocks']:
print "subscribe to masternode"
2014-04-11 20:10:10 +02:00
check_output(["./darkcoind", "-datadir=datadir2", "darksendsub"])
2014-04-08 18:08:05 +02:00
last_block = obj2['blocks']
2014-04-11 20:10:10 +02:00
if obj['entries'] > 0 and obj['state'] == 2:
2014-04-08 18:08:05 +02:00
amount = round((random()*10), 3)
2014-04-11 20:10:10 +02:00
addr = check_output(["./darkcoind", "-datadir=datadir2", "getaccountaddress", str(address_current)]).strip()
2014-04-08 18:08:05 +02:00
address_current += 1
print "Pool is active, sending %s to %s" % (amount, addr)
2014-04-11 20:10:10 +02:00
call(["./darkcoind", "-datadir=datadir2", "darksend", addr, str(amount)])
2014-04-08 18:08:05 +02:00
restart_daemon += 1
2014-04-13 17:17:15 +02:00
if obj['state'] == 6 or obj['state'] == 7:
2014-04-08 18:08:05 +02:00
print "Restarting daemon"
sleep(10)
2014-04-11 20:10:10 +02:00
call(["./darkcoind", "-datadir=datadir2", "stop"])
2014-04-08 18:08:05 +02:00
sleep(10)
2014-04-11 20:10:10 +02:00
call(["./darkcoind", "-datadir=datadir2", "-daemon"])
2014-04-08 18:08:05 +02:00
sleep(60)
restart_daemon = 0
2014-04-12 17:02:31 +02:00
last_block = 0
2014-04-08 18:08:05 +02:00
print "Restarted"
sleep(random()*15)