Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add power to boostx stats #638

Merged
merged 2 commits into from
Jul 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cmd/boostx/stats_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
clinode "github.com/filecoin-project/boost/cli/node"
"github.com/filecoin-project/boost/cmd"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
"github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -44,6 +46,8 @@ var statsCmd = &cli.Command{
wg.Add(len(miners))
var lk sync.Mutex
var withMinPower []address.Address
minerToMinerPower := make(map[address.Address]power.Claim)
minerToTotalPower := make(map[address.Address]power.Claim)

throttle := make(chan struct{}, 50)
for _, miner := range miners {
Expand All @@ -62,6 +66,8 @@ var statsCmd = &cli.Command{
if power.HasMinPower { // TODO: Lower threshold
lk.Lock()
withMinPower = append(withMinPower, miner)
minerToMinerPower[miner] = power.MinerPower
minerToTotalPower[miner] = power.TotalPower
lk.Unlock()
}
}(miner)
Expand All @@ -73,6 +79,9 @@ var statsCmd = &cli.Command{

var boostNodes, marketsNodes, noProtocolsNodes int

boostRawBytePower := big.NewInt(0)
boostQualityAdjPower := big.NewInt(0)

for _, maddr := range withMinPower {
select {
case <-ctx.Done():
Expand Down Expand Up @@ -101,7 +110,14 @@ var statsCmd = &cli.Command{
fmt.Print("Provider " + maddr.String())
if contains(protos, "/fil/storage/mk/1.2.0") {
fmt.Print(" is running boost")
fmt.Println()

fmt.Println("boost provider ", maddr.String(), "raw power:", minerToMinerPower[maddr].RawBytePower)
fmt.Println("boost provider ", maddr.String(), "quality adj power:", minerToMinerPower[maddr].QualityAdjPower)

boostNodes++
boostQualityAdjPower = big.Add(boostQualityAdjPower, minerToMinerPower[maddr].QualityAdjPower)
boostRawBytePower = big.Add(boostRawBytePower, minerToMinerPower[maddr].RawBytePower)
} else if contains(protos, "/fil/storage/mk/1.1.0") {
fmt.Print(" is running markets")
marketsNodes++
Expand All @@ -121,6 +137,8 @@ var statsCmd = &cli.Command{

fmt.Println()
fmt.Println("Total Boost nodes:", boostNodes)
fmt.Println("Total Boost raw power:", boostRawBytePower)
fmt.Println("Total Boost quality adj power:", boostQualityAdjPower)
fmt.Println("Total Lotus Markets nodes:", marketsNodes)
fmt.Println("Total SPs with minimum power: ", len(withMinPower))

Expand Down