Here is a quick patch against work.py which will cause it to log a line to a CSV file every time an actual share is found. I haven't had time to fully work out how to get the hash rate inside that function yet. I'm not sure if you want to only pay out on shares that p2pool counts as valid, or a percentage of the hashrate.
Fields in the CSV are: time.time(), user, on_time, got_share, got_block
root@bitcoin:/var/lib/p2pool/p2pool/p2pool# git diff work.py
diff --git a/p2pool/work.py b/p2pool/work.py
index 7c5823b..a4c3f38 100644
--- a/p2pool/work.py
+++ b/p2pool/work.py
@@ -5,6 +5,8 @@ import random
import sys
import time
+import csv
+
from twisted.internet import defer
from twisted.python import log
@@ -281,6 +283,7 @@ class WorkerBridge(worker_interface.WorkerBridge):
received_header_hashes = set()
def got_response(header, user, coinbase_nonce):
+ got_block, got_share = False, False
assert len(coinbase_nonce) == self.COINBASE_NONCE_LENGTH == 4
new_packed_gentx = packed_gentx[:-4-4] + coinbase_nonce + packed_gentx[-4:] if coinbase_nonce != '\0'*self.COINBASE_NONCE_LENGTH else packed_gentx
new_gentx = bitcoin_data.tx_type.unpack(new_packed_gentx) if coinbase_nonce != '\0'*self.COINBASE_NONCE_LENGTH else gentx
@@ -291,6 +294,7 @@ class WorkerBridge(worker_interface.WorkerBridge):
if pow_hash <= header['bits'].target or p2pool.DEBUG:
helper.submit_block(dict(header=header, txs=[new_gentx] + other_transactions), False, self.node.factory, self.node.bitcoind, self.node.bitcoind_work, self.node.net)
if pow_hash <= header['bits'].target:
+ got_block = True
print
print 'GOT BLOCK FROM MINER! Passing to bitcoind! %s%064x' % (self.node.net.PARENT.BLOCK_EXPLORER_URL_PREFIX, header_hash)
print
@@ -332,6 +336,7 @@ class WorkerBridge(worker_interface.WorkerBridge):
log.err(None, 'Error while processing merged mining POW:')
if pow_hash <= share_info['bits'].target and header_hash not in received_header_hashes:
+ got_share = True
share = get_share(header, pack.IntType(32).unpack(coinbase_nonce))
print 'GOT SHARE! %s %s prev %s age %.2fs%s' % (
@@ -364,6 +369,16 @@ class WorkerBridge(worker_interface.WorkerBridge):
print >>sys.stderr, 'Worker %s submitted share more than once!' % (user,)
else:
received_header_hashes.add(header_hash)
+
+ # P2POOL SHARE LOGGING
+ if got_share or got_block:
+ try:
+ with open('/tmp/p2pool-shares.csv', 'ab') as csvfile:
+ writer = csv.writer(csvfile)
+ writer.writerow([time.time(), user, on_time, got_share, got_block])
+ except:
+ log.err(None, 'Could not save share to pool database')
+
self.pseudoshare_received.happened(bitcoin_data.target_to_average_attempts(target), not on_time, user)
self.recent_shares_ts_work.append((time.time(), bitcoin_data.target_to_average_attempts(target)))