Skip to content

Commit

Permalink
add exchange rate to stats
Browse files Browse the repository at this point in the history
  • Loading branch information
robertlincecum committed May 13, 2024
1 parent cbb8807 commit f630ce3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions quaistats/quaistats.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"errors"
"fmt"
"github.com/dgrijalva/jwt-go"
"github.com/dominant-strategies/go-quai/consensus/misc"
"io/ioutil"
"math/big"
"net"
Expand Down Expand Up @@ -1012,6 +1013,10 @@ type blockDetailStats struct {
Chain string `json:"chain"`
Entropy string `json:"entropy"`
Difficulty string `json:"difficulty"`
QuaiPerQi string `json:"quaiPerQi"`
QuaiReward string `json:"quaiReward"`
QiReward string `json:"qiReward"`
CoinType bool `json:"coinType"`
}

// Everyone sends every block
Expand Down Expand Up @@ -1238,7 +1243,18 @@ func (s *Service) assembleBlockDetailStats(block *types.WorkObject) *blockDetail
if block == nil {
return nil
}
coinType := block.Coinbase().IsInQiLedgerScope()
difficulty := block.Difficulty().String()
quaiPerQi := misc.QiToQuai(block, big.NewInt(1)).String()
var quaiReward *big.Int
var qiReward *big.Int
if coinType {
qiReward = misc.CalculateReward(block)
quaiReward = misc.QiToQuai(block, qiReward)
} else {
quaiReward = misc.CalculateReward(block)
qiReward = misc.QuaiToQi(block, quaiReward)
}

// Assemble and return the block stats
return &blockDetailStats{
Expand All @@ -1249,6 +1265,10 @@ func (s *Service) assembleBlockDetailStats(block *types.WorkObject) *blockDetail
Chain: s.backend.NodeLocation().Name(),
Entropy: common.BigBitsToBits(s.backend.TotalLogS(block)).String(),
Difficulty: difficulty,
QuaiPerQi: quaiPerQi,
QuaiReward: quaiReward.String(),
QiReward: qiReward.String(),
CoinType: coinType,
}
}

Expand Down

0 comments on commit f630ce3

Please sign in to comment.