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-11 20:55:21 +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
|
|
|
|
|
|
|
|
if restart_daemon >= 15:
|
|
|
|
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
|
|
|
|
print "Restarted"
|
|
|
|
|
|
|
|
sleep(random()*15)
|
|
|
|
|