consensus/cmd/web/views/calculate-share-time.qtpl
DataHoarder 4bebd10182
All checks were successful
continuous-integration/drone/push Build is passing
Partially implement #11 Cumulative Share Effort on calculator, added mean shares per day
2024-02-28 05:11:11 +01:00

170 lines
7.4 KiB
Plaintext

{% import "git.gammaspectra.live/P2Pool/p2pool-observer/utils" %}
{% code
type CalculateShareTimePage struct {
// inherit from base page, so its' title is used in error page.
BasePage
Hashrate float64
Magnitude float64
Efforts []CalculateShareTimePageEffortEntry
EstimatedRewardPerDay uint64
EstimatedSharesPerDay float64
EstimatedBlocksPerDay float64
}
%}
{% code
type CalculateShareTimePageEffortEntry struct {
Effort float64
Probability float64
Between float64
BetweenSolo float64
ShareProbabilities []float64
}
%}
{% func (p *CalculateShareTimePage) Title() %}
{%= p.BasePage.Title() %} - Average Share Time Calculator
{% endfunc %}
{% func (p *CalculateShareTimePage) Content() %}
<style type="text/css">
.bulk {
color: #00dddd;
}
.mode {
font-weight: bolder;
/* color: rgb(100,206,145); */
color: #00ffff;
}
</style>
<div style="text-align: center">
<form action="/calculate-share-time" method="get">
<h2>Average Share Time Calculator</h2>
<p>
This tool calculates your average expected time between shares on the pool at current difficulty.
<br/>
<small>Do note this time will vary (can get shares sooner, or later, even way later), depending on your luck, and changing difficulty of the pool due to increase / reductions in hashrate.</small>
<br/>
For lower hashrate, this average is what statistically will be achieved long term.
<br/>
The long term average per-share effort would be <span style="font-weight:bolder; color: {%s effort_color(100) %};">100%</span>
</p>
<div>
<label for="hashrate">Your Hashrate</label><br/>
<input type="numeric" name="hashrate" id="hashrate" placeholder="100" size="8" class="mono" value="{% if p.Hashrate > 0 %}{%s str(p.Hashrate) %}{% endif %}"/>
<select name="magnitude">
<option value="1"{% if p.Magnitude == 1 %} selected{% endif %}>H/s</option>
<option value="1000"{% if p.Magnitude == 1000 %} selected{% endif %}>KH/s</option>
<option value="1000000"{% if p.Magnitude == 1000000 %} selected{% endif %}>MH/s</option>
<option value="1000000000"{% if p.Magnitude == 1000000000 %} selected{% endif %}>GH/s</option>
</select>
</div>
<div style="margin-top: 10px">
<input type="submit" value="Calculate" style="width: 20em;"/>
</div>
</form>
</div>
{% if p.Hashrate > 0 %}
<hr/>
<div style="text-align: center">
<table class="center" style="max-width: calc(15em + 15em + 15em + 15em + 15em);">
{% code between := (float64(p.Context().Pool.SideChain.LastBlock.Difficulty) / (p.Hashrate * p.Magnitude)) %}
{% code between_solo := (float64(p.Context().Pool.MainChain.Difficulty.Lo) / (p.Hashrate * p.Magnitude)) %}
<tr style="line-height: 1.5;">
<td style="width: 15em"><strong>P2Pool Difficulty</strong><br/>{%s si_units(p.Context().Pool.SideChain.LastBlock.Difficulty, 2) %}</td>
<td style="width: 15em"><strong>P2Pool Hashrate</strong><br/>{%s si_units(diff_hashrate(p.Context().Pool.SideChain.LastBlock.Difficulty, p.Context().Consensus.TargetBlockTime), 2) %}H/s</td>
<td style="width: 15em"><strong>Your Hashrate</strong><br/>{%s si_units(p.Hashrate * p.Magnitude, 2) %}H/s</td>
<td title="Mean frequency between P2Pool shares" style="width: 15em; border: #ff6600 dashed 1px;"><strong>Your Share Mean<br/>{%s time_duration_long(between) %}</strong></td>
<td title="Mean P2Pool shares per day" style="width: 15em; border: #ff6600 dashed 1px;"><strong>Your Daily Mean Shares<br/>{%f.3 p.EstimatedSharesPerDay %} share(s)</strong></td>
</tr>
<tr><th colspan="5">&nbsp;</th></tr>
<tr style="line-height: 1.5;">
<td><strong>Monero Difficulty</strong><br/>{%s si_units(p.Context().Pool.MainChain.Difficulty.Lo, 2) %}</td>
<td><strong>Monero Hashrate</strong><br/>{%s si_units(diff_hashrate(p.Context().Pool.MainChain.Difficulty, uint64(p.Context().Pool.MainChain.Consensus.BlockTime)), 2) %}H/s</td>
<td title="Mean frequency between P2Pool finds Monero Blocks"><strong>P2Pool Block Mean</strong><br/><em>{%s time_duration_long(float64(p.Context().Pool.MainChain.Difficulty.Lo) / float64(diff_hashrate(p.Context().Pool.SideChain.LastBlock.Difficulty, p.Context().Consensus.TargetBlockTime))) %}</em></td>
<td title="Mean frequency between Solo Monero Blocks (without P2Pool)"><strong>Your Solo Block Mean</strong><br/><em>{%s time_duration_long(between_solo) %}</em></td>
<td title="Mean Solo Monero Blocks (without P2Pool) per day"><strong>Your Solo Daily Mean Blocks</strong><br/><em>{%f.3 p.EstimatedBlocksPerDay %} block(s)</em></td>
</tr>
<tr><th colspan="5">&nbsp;</th></tr>
<tr style="line-height: 1.5; font-size: 21px;"><td></td><td colspan="3" style="border: #ff6600 dashed 1px;"><strong>Your Estimated Daily Reward</strong><br/>{%s monero_to_xmr(p.EstimatedRewardPerDay) %} XMR</td><td></td></tr>
</table>
<br/>
<h3>Single Share Effort</h3>
<table class="center" style="max-width: calc(10em + 15em + 15em + 15em);">
<tr style="line-height: 1.5;">
<th>Share Effort</th>
<th>Found Probability</th>
<th>P2Pool Estimate</th>
<th>Solo Estimate</th>
</tr>
{% for _, e := range p.Efforts %}
<tr>
<td style="font-size: 17px; font-weight:bolder; color: {%s effort_color(e.Effort) %};">
{%f.0 e.Effort %}%
</td>
<td title="Chance share is not found before: {%f.5 100 - e.Probability %}%">
{%f.5 e.Probability %}%
</td>
<td>
{%s time_duration_long(e.Between) %}
</td>
<td>
{%s time_duration_long(e.BetweenSolo) %}
</td>
</tr>
{% endfor %}
</table>
<br/>
<h3>Cumulative Share Effort</h3>
<table class="center" style="max-width: calc(15em + 15em + {%d len(p.Efforts[0].ShareProbabilities)*2 %}em);">
<tr>
<th colspan="2"></th>
<th colspan="{%d len(p.Efforts[0].ShareProbabilities) %}">Number of shares</th>
</tr>
<tr style="line-height: 1.5;">
<th>Cumulative Effort</th>
<th>Cumulative Time</th>
{% for i := range p.Efforts[0].ShareProbabilities %}
<th>{%d i %}</th>
{% endfor %}
</tr>
{% for _, e := range p.Efforts %}
<tr>
<td style="font-size: 17px; font-weight:bolder; color: {%s effort_color(e.Effort) %};">
{%f.0 e.Effort %}%
</td>
<td>
{%s time_duration_long(e.Between) %}
</td>
{% code var mode = utils.ProbabilityMode(e.ShareProbabilities...) %}
{% for _, p := range e.ShareProbabilities %}
{% if p*100 > 1 %}
<td class="{% if mode == p %}mode{% else %}{% endif %}" title="{%f.5 p*100 %}%">{%f.0 p*100 %}%</td>
{% else %}
<td title="{%f.5 p*100 %}%"></td>
{% endif %}
{% endfor %}
</tr>
{% endfor %}
<tr>
<th colspan="2"></th>
{% for i := range p.Efforts[0].ShareProbabilities %}
<th>{%d i %}</th>
{% endfor %}
</tr>
</table>
</div>
{% endif %}
{% endfunc %}