forked from forbole/juno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
33 lines (26 loc) · 827 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package parser
import (
tmctypes "github.com/cometbft/cometbft/rpc/core/types"
tmtypes "github.com/cometbft/cometbft/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/gotabit/juno/v5/types"
)
// findValidatorByAddr finds a validator by a consensus address given a set of
// Tendermint validators for a particular block. If no validator is found, nil
// is returned.
func findValidatorByAddr(consAddr string, vals *tmctypes.ResultValidators) *tmtypes.Validator {
for _, val := range vals.Validators {
if consAddr == sdk.ConsAddress(val.Address).String() {
return val
}
}
return nil
}
// sumGasTxs returns the total gas consumed by a set of transactions.
func sumGasTxs(txs []*types.Tx) uint64 {
var totalGas uint64
for _, tx := range txs {
totalGas += uint64(tx.GasUsed)
}
return totalGas
}