res = dict((k, v/dt) for k, v in res.iteritems())
return res
+def get_user_stale_props(tracker, share_hash, lookbehind):
+ res = {}
+ for share in tracker.get_chain(share_hash, lookbehind - 1):
+ stale, total = res.get(share.share_data['pubkey_hash'], (0, 0))
+ total += 1
+ if share.share_data['stale_info'] is not None:
+ stale += 1
+ total += 1
+ res[share.share_data['pubkey_hash']] = stale, total
+ return dict((pubkey_hash, stale/total) for pubkey_hash, (stale, total) in res.iteritems())
+
def get_expected_payouts(tracker, best_share_hash, block_target, subsidy, net):
weights, total_weight, donation_weight = tracker.get_cumulative_weights(best_share_hash, min(tracker.get_height(best_share_hash), net.REAL_CHAIN_LENGTH), 65535*net.SPREAD*bitcoin_data.target_to_average_attempts(block_target))
res = dict((script, subsidy*weight//total_weight) for script, weight in weights.iteritems())
web_root.putChild('rate', WebInterface(lambda: p2pool_data.get_pool_attempts_per_second(tracker, best_share_var.value, 720)/(1-p2pool_data.get_average_stale_prop(tracker, best_share_var.value, 720))))
web_root.putChild('difficulty', WebInterface(lambda: bitcoin_data.target_to_difficulty(tracker.items[best_share_var.value].max_target)))
web_root.putChild('users', WebInterface(get_users))
+ web_root.putChild('user_stales', WebInterface(lambda: dict((bitcoin_data.pubkey_hash_to_address(ph, net.PARENT), prop) for ph, prop in
+ p2pool_data.get_user_stale_props(tracker, best_share_var.value, tracker.get_height(best_share_var.value)).iteritems())))
web_root.putChild('fee', WebInterface(lambda: worker_fee))
web_root.putChild('current_payouts', WebInterface(lambda: dict((bitcoin_data.script2_to_address(script, net.PARENT), value/1e8) for script, value in get_current_txouts().iteritems())))
web_root.putChild('patron_sendmany', WebInterface(get_patron_sendmany, 'text/plain'))