Author

Topic: Performance Counter Patch and RPC extensions (Read 10002 times)

member
Activity: 103
Merit: 61
August 03, 2010, 07:21:38 PM
#3
Nice work Wink  You don't love it till you miss it.
full member
Activity: 210
Merit: 100
Here's a little python program I wrote that checks to see if you have a bitcoin balance and, if so, sends it to a stored address. I use it with a cron job on my headless Bitcoin generating box to keep my main wallet fed with coins.

Code:
#!/usr/bin/python
import subprocess,sys
MyBCAddress = 'PUT YOUR BITCOIN ADDRESS HERE'

p = subprocess.Popen(['bitcoin','getbalance'],stdout=subprocess.PIPE)
out,err = p.communicate()

out = out.strip()

try:
    bal = float(out)
except ValueError:
    sys.exit(1)

if bal > 0.01:
    print "We have a balance of {0:.2f}BC. Sending...".format(bal)
    p = subprocess.Popen(['bitcoin','sendtoaddress',MyBCAddress,str(bal)],stdout=subprocess.PIPE)
    out,err = p.communicate()
    print out
else:
    print "No coins here."
full member
Activity: 210
Merit: 100
After an IRC session, I modified laszlo's bitcoin performance patch to be slightly faster and cleaner. I also added two rpc calls: listgenerated which just lists the strings from the UI of any generated blocks (nice for headless bitcoin mining servers) and gethps which returns the performance count in RPC. I also added gethps to the end of getinfo. Finally, I fixed GCC's issue with optimizations and htons in net.h.

I've mentioned all of these patches elsewhere, but laszlo suggested that I compile them into one patch and post it. Here's that patch:
http://www.alloscomp.com/bitcoin/bitcoin-svn-80-combined-2010-06-07.patch
http://www.alloscomp.com/bitcoin/bitcoin-svn-81-combined-2010-06-11.patch
^ Updated for r81.
Check out http://www.alloscomp.com/bitcoin. The latest version is there.

Enjoy!
Jump to: