#### Repository https://github.com/sau412/arikado_gridcoin_pool #### Introduction New version: added redirect failover, more information about SQL errors in logs, magnitude information. #### Details ##### Redirect failover Pool site uses redirects when performing actions. Redirect requires HTTP header 'Location'. But headers cannot be sent when page text is sent or warnings appear. So it fixed with redirect function, which also checks is headers sent. If they are send, special message added to log: ```` // Redirect and die function html_redirect_and_die($url) { $file=""; $line=0; if(headers_sent($file,$line)) { auth_log("Redirect warning: headers already sent, file '$file', line '$line'"); echo "<br>Auto redirect failed, please <a href='$url'>click here</a>"; } else { header("Location: $url"); } die(); } ```` Github commit function: https://github.com/sau412/arikado_gridcoin_pool/commit/b100ef22d615c715dd407f2f2bc7adc6d0b79853 Github commit usage: https://github.com/sau412/arikado_gridcoin_pool/commit/e9dff39fe0de3379419e9b61153ef119bfdbb2e5 It is not seen by users, so no screenshots. ##### Magnitude Magnitude shows user relative contribution. It is used for calculating rewards and for ratings. So it appear multiple times here and there. So I created functions to boincmgr.php receive information from single place: ```` // Get magnitude per project function boincmgr_get_mag_per_project() { $magnitude_total=115000; $whiltelisted_count=db_query_to_variable("SELECT count(*) FROM `boincmgr_projects` WHERE `status` IN ('enabled','auto enabled','stats only')"); if($whiltelisted_count!=0) $mag_per_project=$magnitude_total/$whiltelisted_count; else $mag_per_project=0; return $mag_per_project; } // Get magnitude unit function boincmgr_get_magnitude_unit() { return boincmgr_get_variable("magnitude_unit"); } // Get project host relative contribution function boincmgr_get_relative_contribution_project_host($project_uid,$host_uid) { $project_uid_escaped=db_escape($project_uid); $host_uid_escaped=db_escape($host_uid); $relative_contribution=db_query_to_variable("SELECT SUM(bphl.`expavg_credit`/bp.`team_expavg_credit`) FROM `boincmgr_project_hosts_last` AS bphl LEFT OUTER JOIN `boincmgr_projects` AS bp ON bp.uid=bphl.project_uid WHERE bphl.`project_uid`='$project_uid_escaped' AND bphl.`host_uid`='$host_uid_escaped' AND bp.`status` IN ('enabled','auto enabled','stats only')"); if($relative_contribution=="") $relative_contribution=0; return $relative_contribution; } // Get project user relative contribution function boincmgr_get_relative_contribution_project_user($project_uid,$user_uid) { $project_uid_escaped=db_escape($project_uid); $user_uid_escaped=db_escape($user_uid); $relative_contribution=db_query_to_variable("SELECT SUM(bphl.`expavg_credit`/bp.`team_expavg_credit`) FROM `boincmgr_project_hosts_last` AS bphl LEFT OUTER JOIN `boincmgr_projects` AS bp ON bp.uid=bphl.project_uid LEFT OUTER JOIN `boincmgr_hosts` AS bh ON bh.uid=bphl.host_uid WHERE bphl.`project_uid`='$project_uid_escaped' AND bh.`username_uid`='$user_uid_escaped' AND bp.`status` IN ('enabled','auto enabled','stats only')"); if($relative_contribution=="") $relative_contribution=0; return $relative_contribution; } // Get project relative contribution function boincmgr_get_relative_contribution_project($project_uid) { $project_uid_escaped=db_escape($project_uid); $relative_contribution=db_query_to_variable("SELECT SUM(bp.`expavg_credit`/bp.`team_expavg_credit`) FROM `boincmgr_projects` AS bp WHERE bp.`uid`='$project_uid_escaped' AND bp.`status` IN ('enabled','auto enabled','stats only')"); if($relative_contribution=="") $relative_contribution=0; return $relative_contribution; } // Get host relative contribution function boincmgr_get_relative_contribution_host($host_uid) { $host_uid_escaped=db_escape($host_uid); $relative_contribution=db_query_to_variable("SELECT SUM(bphl.`expavg_credit`/bp.`team_expavg_credit`) FROM `boincmgr_project_hosts_last` AS bphl LEFT OUTER JOIN `boincmgr_projects` AS bp ON bp.uid=bphl.project_uid WHERE bphl.`host_uid`='$host_uid_escaped' AND bp.`status` IN ('enabled','auto enabled','stats only')"); if($relative_contribution=="") $relative_contribution=0; return $relative_contribution; } // Get user relative contribution function boincmgr_get_relative_contribution_user($user_uid) { $user_uid_escaped=db_escape($user_uid); $relative_contribution=db_query_to_variable("SELECT SUM(bphl.`expavg_credit`/bp.`team_expavg_credit`) FROM `boincmgr_project_hosts_last` AS bphl LEFT OUTER JOIN `boincmgr_projects` AS bp ON bp.uid=bphl.project_uid LEFT OUTER JOIN `boincmgr_hosts` AS bh ON bh.uid=bphl.host_uid WHERE bh.`username_uid`='$user_uid_escaped' AND bp.`status` IN ('enabled','auto enabled','stats only')"); if($relative_contribution=="") $relative_contribution=0; return $relative_contribution; } ```` Functions look similar, but have different groupings. Also function boincmgr_get_relative_contribution_project using different tables. So distinct functions is better than one big function with multiple arguments. Github commit functions: https://github.com/sau412/arikado_gridcoin_pool/commit/20ca4216ba0bbb5eb94d62359902bfd38d66f67b Now I can use: ```` $mag_per_project=boincmgr_get_mag_per_project(); $magnitude_unit=boincmgr_get_magnitude_unit(); <...> $host_relative_contribution=boincmgr_get_relative_contribution_project_host($project_uid,$host_uid); $mag_formatted=sprintf("%0.2f",$mag_per_project*$host_relative_contribution); ```` instead of multiple implementations of ```` // GRC per last day $total_grc_per_day=db_query_to_variable("SELECT SUM(`mint`-`interest`) FROM `boincmgr_blocks` WHERE cpid<>'INVESTOR' AND date_sub(NOW(), INTERVAL 1 DAY)<`timestamp`"); <...> // Whitelisted projects count $whiltelisted_count=db_query_to_variable("SELECT count(*) FROM `boincmgr_projects` WHERE `status` IN ('enabled','auto enabled','stats only')"); if($whiltelisted_count>0) $grc_per_day_est=($total_grc_per_day/$whiltelisted_count)*($relative_credit); else $grc_per_day_est=0; $grc_per_day_est=round($grc_per_day_est,4); ```` Github commit usage: https://github.com/sau412/arikado_gridcoin_pool/commit/b100ef22d615c715dd407f2f2bc7adc6d0b79853 Interface screenshots (one of the ratings): ![](https://cdn.steemitimages.com/DQmd7UkqvLqkhcwWUmvgL1WvuXfyu6WBtzM7smALneskQXP/%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5.png) URL: https://grc.arikado.ru/#rating_by_user_mag Also I can add magnitude information to other places, like host settings (visible after green fields 'synced, checked'): ![](https://cdn.steemitimages.com/DQmSW3BGaxm7PNezhG2w9eStrEdhcgNpYoFXep4foeY3iVB/%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5.png) ##### Stack trace to log Using that part of db_query function I can see stack trace in the log when SQL error received: ```` $debug_backtrace_array=debug_backtrace(); $backtrace_string="Stack trace:\n"; foreach($debug_backtrace_array as $stack_info) { $file=$stack_info['file']; $line=$stack_info['line']; $func=$stack_info['function']; $args=implode("','",$stack_info['args']); $backtrace_string.="File '$file' line '$line' function '$func' arguments '$args'\n"; } auth_log($backtrace_string); ```` Github commit: https://github.com/sau412/arikado_gridcoin_pool/commit/3b8da9f09eeeddd714451b191872ec473840abfc This is how it looks in administrative interface: ![](https://cdn.steemitimages.com/DQmbKCgJxJaokS7jSedu5dMkd3xrXSwmBcAdCZ1hnBeSXwz/%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5.png) Don't worry about cookie key, it exists only in development server. #### Summary All these changes included in version v1.1 of the pool #### Resources Working implementation of the pool: https://gridcoinpool.ru/ Rating view: https://grc.arikado.ru/#rating_by_user_mag Release of v1.1: https://github.com/sau412/arikado_gridcoin_pool/tree/v1.1
post_id | 59,674,732 |
---|---|
author | sau412 |
permlink | development-log-for-arikado-gridcoin-pool |
category | utopian-io |
json_metadata | {"tags":["utopian-io","blog","gridcoin","pool","development"],"format":"markdown","image":["https:\/\/cdn.steemitimages.com\/DQmd7UkqvLqkhcwWUmvgL1WvuXfyu6WBtzM7smALneskQXP\/%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5.png"],"app":"steemit\/0.1","links":["https:\/\/github.com\/sau412\/arikado_gridcoin_pool","https:\/\/github.com\/sau412\/arikado_gridcoin_pool\/commit\/b100ef22d615c715dd407f2f2bc7adc6d0b79853","https:\/\/github.com\/sau412\/arikado_gridcoin_pool\/commit\/e9dff39fe0de3379419e9b61153ef119bfdbb2e5","https:\/\/github.com\/sau412\/arikado_gridcoin_pool\/commit\/20ca4216ba0bbb5eb94d62359902bfd38d66f67b","https:\/\/grc.arikado.ru\/#rating_by_user_mag","https:\/\/github.com\/sau412\/arikado_gridcoin_pool\/commit\/3b8da9f09eeeddd714451b191872ec473840abfc","https:\/\/gridcoinpool.ru\/","https:\/\/github.com\/sau412\/arikado_gridcoin_pool\/tree\/v1.1"]} |
created | 2018-08-14 13:14:48 |
last_update | 2018-08-14 13:14:48 |
depth | 0 |
children | 5 |
net_rshares | 21,917,712,967,647 |
last_payout | 2018-08-21 13:14:48 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 22.553 SBD |
curator_payout_value | 7.380 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 8,258 |
author_reputation | 8,211,914,981,540 |
root_title | "Development Log for arikado gridcoin pool" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
cm-steem | 0 | 621,654,222,002 | 100% | ||
vortac | 0 | 1,240,278,887,710 | 34% | ||
barton26 | 0 | 10,819,655,457 | 100% | ||
miniature-tiger | 0 | 106,547,797,461 | 100% | ||
nexusprime | 0 | 2,013,892,980 | 100% | ||
grider123 | 0 | 2,077,621,536 | 100% | ||
darkhejmaster | 0 | 610,756,888 | 100% | ||
theissen | 0 | 2,281,657,125 | 100% | ||
parejan | 0 | 10,946,557,623 | 100% | ||
crokkon | 0 | 23,620,286,863 | 40% | ||
osm0sis | 0 | 9,201,568,091 | 20% | ||
jrawsthorne | 0 | 6,004,597,798 | 100% | ||
hotbit | 0 | 24,188,901,790 | 100% | ||
donkeykong9000 | 0 | 239,649,339,242 | 100% | ||
utopian-io | 0 | 18,993,318,267,142 | 12.48% | ||
favcau | 0 | 36,259,104,061 | 50% | ||
zapncrap | 0 | 18,624,700,812 | 50% | ||
wisecracka | 0 | 598,124,036 | 100% | ||
mvanyi | 0 | 1,598,929,266 | 100% | ||
alexmaksto | 0 | 552,713,020 | 100% | ||
amosbastian | 0 | 14,475,890,228 | 22.69% | ||
curx | 0 | 17,557,544,562 | 50% | ||
properfraction | 0 | 717,516,715 | 100% | ||
sandyprasasty | 0 | 342,209,241 | 100% | ||
grwd | 0 | 2,182,529,922 | 100% | ||
steemgridcoin | 0 | 2,858,173,920 | 100% | ||
nathanielcwm | 0 | 59,867,002 | 100% | ||
kolxoznik0 | 0 | 521,571,425 | 100% | ||
igorik | 0 | 521,755,268 | 100% | ||
remind-me | 0 | 66,084,563 | 100% | ||
nevisajar | 0 | 530,125,108 | 100% | ||
jmartinz | 0 | 520,982,331 | 100% | ||
mightypanda | 0 | 19,790,159,076 | 100% | ||
whimperrubbery | 0 | 520,982,331 | 100% | ||
dalz | 0 | 1,161,044,773 | 100% | ||
truthly | 0 | 53,905,975 | 100% | ||
mothersmerlin | 0 | 530,116,655 | 100% | ||
wagcouloir | 0 | 514,883,418 | 100% | ||
magicagree | 0 | 514,880,545 | 100% | ||
servletbookmark | 0 | 514,883,418 | 100% | ||
sordinistoat | 0 | 520,973,805 | 100% | ||
riemannevening | 0 | 514,880,545 | 100% | ||
appearford | 0 | 514,880,545 | 100% | ||
shishir2584 | 0 | 76,204,421 | 100% | ||
twittercohort | 0 | 520,909,847 | 100% | ||
steem-ua | 0 | 499,158,240,984 | 23.44% | ||
sashashelest | 0 | 513,885,934 | 100% | ||
roma.kisov | 0 | 519,943,440 | 100% | ||
kostya.borisenko | 0 | 519,926,567 | 100% | ||
kaczynski | 0 | 50,434,180 | 100% | ||
bit2048 | 0 | 0 | 100% |
This post contains the information it is meant to convey, and has the relevant graphical illustrations. However, I have some tips and suggestions on improving future posts. I would have liked to have seen more detail, and especially explanation. The post includes almost no information on what the project actually is, and I would strongly recommend starting with that. The post could be better written, and could have used a proofreading. I would recommend putting the text - minus the code, of course - in [Hemingway](http://www.hemingwayapp.com/) to get help with style and grammar. For folks who want to get the information, it is important that the post be easy to read and understand. I would also recommend adding links to past posts explaining in greater detail what the project is about. I know those are available further down in your blog, but why not make it easier for users to find? Again, making things easier for users is highly important, especially in a post as technical as this one. I look forward to seeing future posts from you. Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category. To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/1/43321212). ---- Need help? Write a ticket on https://support.utopian.io/. Chat with us on [Discord](https://discord.gg/uTyJkNm). [[utopian-moderator]](https://join.utopian.io/)
post_id | 59,685,964 |
---|---|
author | didic |
permlink | re-sau412-development-log-for-arikado-gridcoin-pool-20180814t152654474z |
category | utopian-io |
json_metadata | {"links":["http:\/\/www.hemingwayapp.com\/","https:\/\/join.utopian.io\/guidelines","https:\/\/review.utopian.io\/result\/1\/43321212","https:\/\/support.utopian.io\/","https:\/\/discord.gg\/uTyJkNm","https:\/\/join.utopian.io\/"],"app":"steemit\/0.1","tags":["utopian-io"]} |
created | 2018-08-14 15:26:54 |
last_update | 2018-08-14 15:26:54 |
depth | 1 |
children | 3 |
net_rshares | 4,595,418,033,250 |
last_payout | 2018-08-21 15:26:54 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 4.688 SBD |
curator_payout_value | 1.558 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 1,548 |
author_reputation | 76,442,227,425,259 |
root_title | "Development Log for arikado gridcoin pool" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
barton26 | 0 | 10,595,413,893 | 100% | ||
crokkon | 0 | 2,467,791,164 | 4% | ||
espoem | 0 | 18,811,642,430 | 15% | ||
utopian-io | 0 | 4,558,311,689,267 | 2.73% | ||
zapncrap | 0 | 1,972,027,144 | 5% | ||
curx | 0 | 1,734,078,475 | 5% | ||
dalz | 0 | 1,188,688,696 | 100% | ||
mops2e | 0 | 336,702,181 | 10% |
Should I edit this post or just include required information in next post?
post_id | 59,694,259 |
---|---|
author | sau412 |
permlink | re-didic-re-sau412-development-log-for-arikado-gridcoin-pool-20180814t165818270z |
category | utopian-io |
json_metadata | {"app":"steemit\/0.1","tags":["utopian-io"]} |
created | 2018-08-14 16:58:18 |
last_update | 2018-08-14 16:58:18 |
depth | 2 |
children | 1 |
net_rshares | 0 |
last_payout | 2018-08-21 16:58:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 74 |
author_reputation | 8,211,914,981,540 |
root_title | "Development Log for arikado gridcoin pool" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
An edit could be useful for readers, and I would applaud it. However, for Utopian purposes, the post has been scored. I would definitely incorporate the recommendations in future posts.
post_id | 59,694,753 |
---|---|
author | didic |
permlink | re-sau412-re-didic-re-sau412-development-log-for-arikado-gridcoin-pool-20180814t170357528z |
category | utopian-io |
json_metadata | {"app":"steemit\/0.1","tags":["utopian-io"]} |
created | 2018-08-14 17:03:57 |
last_update | 2018-08-14 19:30:48 |
depth | 3 |
children | 0 |
net_rshares | 0 |
last_payout | 2018-08-21 17:03:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 185 |
author_reputation | 76,442,227,425,259 |
root_title | "Development Log for arikado gridcoin pool" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
Thank you for your review, @didic! So far this week you've reviewed 24 contributions. Keep up the good work!
post_id | 59,756,990 |
---|---|
author | utopian-io |
permlink | re-re-sau412-development-log-for-arikado-gridcoin-pool-20180814t152654474z-20180815t091509z |
category | utopian-io |
json_metadata | {"app":"beem\/0.19.42"} |
created | 2018-08-15 09:15:09 |
last_update | 2018-08-15 09:15:09 |
depth | 2 |
children | 0 |
net_rshares | 0 |
last_payout | 2018-08-22 09:15:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 109 |
author_reputation | 152,913,012,544,965 |
root_title | "Development Log for arikado gridcoin pool" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
Hey @sau412 **Thanks for contributing on Utopian**. Weβre already looking forward to your next contribution! **Want to chat? Join us on Discord https://discord.gg/h52nFrV.** <a href='https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
post_id | 59,895,360 |
---|---|
author | utopian-io |
permlink | re-development-log-for-arikado-gridcoin-pool-20180816t172008z |
category | utopian-io |
json_metadata | {"app":"beem\/0.19.42"} |
created | 2018-08-16 17:20:09 |
last_update | 2018-08-16 17:20:09 |
depth | 1 |
children | 0 |
net_rshares | 16,384,731,886 |
last_payout | 2018-08-23 17:20:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.016 SBD |
curator_payout_value | 0.004 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 299 |
author_reputation | 152,913,012,544,965 |
root_title | "Development Log for arikado gridcoin pool" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
espoem | 0 | 16,064,864,814 | 15% | ||
mops2e | 0 | 319,867,072 | 10% |