Fix effort values
This commit is contained in:
parent
b84b607c6c
commit
2dc10c486f
13
bot.go
13
bot.go
|
@ -1,7 +1,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
|
@ -226,25 +225,25 @@ func main() {
|
|||
//new block
|
||||
e.LastBlocks = append(e.LastBlocks, b)
|
||||
|
||||
uHeight := (b.SideHeight << 16) | uint64(binary.BigEndian.Uint16(b.MainBlock.Id[0:2]))
|
||||
uHeight := (b.SideHeight << 16) | (uint64(b.MainBlock.Id[0]) << 8) | uint64(b.MainBlock.Id[1])
|
||||
effort := float64(0)
|
||||
if previous := e.LastBlocks.GetPrevious(b); previous != nil {
|
||||
effort = float64(b.CumulativeDifficulty.SubWrap(previous.CumulativeDifficulty).Mul64(100).Lo) / float64(b.Difficulty)
|
||||
effort = float64(b.CumulativeDifficulty.SubWrap(previous.CumulativeDifficulty).Mul64(100).Lo) / float64(b.MainBlock.Difficulty)
|
||||
}
|
||||
effortColor := FormatColorRed
|
||||
if effort < 2 {
|
||||
if effort < 200 {
|
||||
effortColor = FormatColorYellow
|
||||
}
|
||||
if effort < 1 {
|
||||
if effort < 100 {
|
||||
effortColor = FormatColorGreen
|
||||
}
|
||||
bot.Msg(e.Channel, fmt.Sprintf(
|
||||
"%sBLOCK FOUND%s on %s: Main height %s%d%s, Side height %d :: %s/s/%s :: Effort %s%.02f%s :: %s%d miners paid%s, total %s%s%s XMR%s :: Id %s%s",
|
||||
"%sBLOCK FOUND%s on %s: Main height %s%d%s, Side height %d :: %s/s/%s :: Effort %s%.02f%%%s :: %s%d miners paid%s, total %s%s%s XMR%s :: Id %s%s",
|
||||
FormatColorLightGreen+FormatBold, FormatReset, e.Name,
|
||||
FormatColorRed, b.MainBlock.Height, FormatReset,
|
||||
b.SideHeight,
|
||||
e.ApiEndpoint, utils.EncodeBinaryNumber(uHeight),
|
||||
effortColor, effort*100, FormatReset,
|
||||
effortColor, effort, FormatReset,
|
||||
FormatColorOrange, b.WindowOutputs, FormatReset,
|
||||
FormatColorOrange, FormatBold, utils.XMRUnits(b.MainBlock.Reward), FormatReset,
|
||||
FormatItalic, utils.Shorten(b.MainBlock.Id.String(), 8),
|
||||
|
|
Loading…
Reference in a new issue