Skip to content

Commit

Permalink
Stats should only run if node is processing state
Browse files Browse the repository at this point in the history
  • Loading branch information
jdowning100 authored and gameofpointers committed May 22, 2024
1 parent 23fd370 commit 8a7e271
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cmd/utils/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func makeFullNode(p2p quai.NetworkingAPI, nodeLocation common.Location, slicesRu
backend, _ := RegisterQuaiService(stack, p2p, cfg.Quai, cfg.Node.NodeLocation.Context(), currentExpansionNumber, startingExpansionNumber, genesisBlock, logger)
sendfullstats := viper.GetBool(SendFullStatsFlag.Name)
// Add the Quai Stats daemon if requested.
if cfg.Quaistats.URL != "" {
if cfg.Quaistats.URL != "" && backend.ProcessingState() {
RegisterQuaiStatsService(stack, backend, cfg.Quaistats.URL, sendfullstats)
}
return stack, backend
Expand Down
37 changes: 20 additions & 17 deletions core/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ func (sl *Slice) Append(header *types.WorkObject, domPendingHeader *types.WorkOb
// Relay the new pendingHeader
sl.relayPh(block, pendingHeaderWithTermini, domOrigin, block.Location(), subReorg)

inputs, outputs := block.InputsAndOutputsWithoutCoinbase()
net := int(outputs) - int(inputs)
time10 := common.PrettyDuration(time.Since(start))
sl.logger.WithFields(log.Fields{
"t0_1": time0_1,
Expand All @@ -447,23 +449,24 @@ func (sl *Slice) Append(header *types.WorkObject, domPendingHeader *types.WorkOb
}).Info("Times during sub append")

sl.logger.WithFields(log.Fields{
"number": block.NumberArray(),
"hash": block.Hash(),
"difficulty": block.Difficulty(),
"uncles": len(block.Uncles()),
"totalTxs": len(block.Transactions()),
"etxs emitted": len(block.ExtTransactions()),
"qiTxs": len(block.QiTransactions()),
"quaiTxs": len(block.QuaiTransactions()),
"etxs inbound": len(block.Body().ExternalTransactions()),
"gas": block.GasUsed(),
"gasLimit": block.GasLimit(),
"evmRoot": block.EVMRoot(),
"utxoRoot": block.UTXORoot(),
"etxSetRoot": block.EtxSetRoot(),
"order": order,
"location": block.Location(),
"elapsed": common.PrettyDuration(time.Since(start)),
"number": block.NumberArray(),
"hash": block.Hash(),
"difficulty": block.Difficulty(),
"uncles": len(block.Uncles()),
"totalTxs": len(block.Transactions()),
"etxs emitted": len(block.ExtTransactions()),
"qiTxs": len(block.QiTransactions()),
"net outputs-inputs": net,
"quaiTxs": len(block.QuaiTransactions()),
"etxs inbound": len(block.Body().ExternalTransactions()),
"gas": block.GasUsed(),
"gasLimit": block.GasLimit(),
"evmRoot": block.EVMRoot(),
"utxoRoot": block.UTXORoot(),
"etxSetRoot": block.EtxSetRoot(),
"order": order,
"location": block.Location(),
"elapsed": common.PrettyDuration(time.Since(start)),
}).Info("Appended new block")

if nodeCtx == common.ZONE_CTX {
Expand Down
16 changes: 16 additions & 0 deletions core/types/wo.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,22 @@ func (wo *WorkObject) QuaiTransactionsWithoutCoinbase() []*Transaction {
return quaiTxs
}

func (wo *WorkObject) InputsAndOutputsWithoutCoinbase() (uint, uint) {
inputs := 0
outputs := 0
for i, tx := range wo.Transactions() {
if i == 0 && IsCoinBaseTx(tx, wo.woHeader.parentHash, wo.woHeader.location) {
// ignore the Qi coinbase tx
continue
}
if tx.Type() == QiTxType {
inputs += len(tx.TxIn())
outputs += len(tx.TxOut())
}
}
return uint(inputs), uint(outputs)
}

func (wo *WorkObject) QuaiTransactionsWithFees() []*Transaction {
quaiTxs := make([]*Transaction, 0)
for _, t := range wo.Transactions() {
Expand Down

0 comments on commit 8a7e271

Please sign in to comment.