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

feat: add proving deadline option view live sectors information #8721

Merged

Conversation

beck-8
Copy link
Contributor

@beck-8 beck-8 commented May 25, 2022

Related Issues

Proposed Changes

Additional Info

Checklist

Before you mark the PR ready for review, please make sure that:

  • All commits have a clear commit message.
  • The PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, INTERFACE BREAKING CHANGE, CONSENSUS BREAKING, build, chore, ci, docs,perf, refactor, revert, style, test
    • area: api, chain, state, vm, data transfer, market, mempool, message, block production, multisig, networking, paychan, proving, sealing, wallet, deps
  • This PR has tests for new functionality or change in behaviour
  • If new user-facing features are introduced, clear usage guidelines and / or documentation updates should be included in https://lotus.filecoin.io or Discussion Tutorials.
  • CI is green

@beck-8 beck-8 requested a review from a team as a code owner May 25, 2022 03:33
@beck-8 beck-8 changed the title feat/add proving deadline view live sectors information feat: add proving deadline view live sectors information May 25, 2022
@beck-8 beck-8 changed the title feat: add proving deadline view live sectors information feat: add proving deadline option view live sectors information May 25, 2022
@jennijuju
Copy link
Member

If new user-facing features are introduced, clear usage guidelines and / or documentation updates should be included in https://lotus.filecoin.io/

thanks for contributing - could you please also add user documentation as suggested in the PR template?

@beck-8
Copy link
Contributor Author

beck-8 commented May 25, 2022

If new user-facing features are introduced, clear usage guidelines and / or documentation updates should be included in https://lotus.filecoin.io/

thanks for contributing - could you please also add user documentation as suggested in the PR template?

yes,I will write user documentation later in Discussion Tutorials

@beck-8
Copy link
Contributor Author

beck-8 commented May 25, 2022

If new user-facing features are introduced, clear usage guidelines and / or documentation updates should be included in https://lotus.filecoin.io/

thanks for contributing - could you please also add user documentation as suggested in the PR template?

user documentation already added @jennijuju
#8723

@jennijuju jennijuju requested a review from geoff-vball June 20, 2022 17:49
Comment on lines 252 to 291
if cctx.Bool("live") {
for _, partition := range partitions {
sc, err := partition.LiveSectors.Count()
if err != nil {
return err
}

sectors += sc
if sc > 0 {
PartitionSum++
}

sectors += sc

fc, err := partition.FaultySectors.Count()
if err != nil {
return err
}

faults += fc

fc, err := partition.FaultySectors.Count()
if err != nil {
return err
}
} else {
for _, partition := range partitions {
PartitionSum++

faults += fc
}
sc, err := partition.AllSectors.Count()
if err != nil {
return err
}

sectors += sc

fc, err := partition.FaultySectors.Count()
if err != nil {
return err
}

faults += fc
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too much duplicated code. You should be able to make this work with an if/else statement that either uses partition.LiveSectors.Count() or partition.AllSectors.Count()

Comment on lines 364 to 419
if !cctx.Bool("live") {
for pIdx, partition := range partitions {
sectorCount, err := partition.AllSectors.Count()
if err != nil {
return err
}

sectorNumbers, err := partition.AllSectors.All(sectorCount)
if err != nil {
return err
}
sectorNumbers, err := partition.AllSectors.All(sectorCount)
if err != nil {
return err
}

faultsCount, err := partition.FaultySectors.Count()
if err != nil {
return err
}
faultsCount, err := partition.FaultySectors.Count()
if err != nil {
return err
}

fn, err := partition.FaultySectors.All(faultsCount)
if err != nil {
return err
fn, err := partition.FaultySectors.All(faultsCount)
if err != nil {
return err
}

fmt.Printf("Partition Index: %d\n", pIdx)
fmt.Printf("Sectors: %d\n", sectorCount)
fmt.Printf("Sector Numbers: %v\n", sectorNumbers)
fmt.Printf("Faults: %d\n", faultsCount)
fmt.Printf("Faulty Sectors: %d\n", fn)
}
} else {
for pIdx, partition := range partitions {
sectorCount, err := partition.LiveSectors.Count()
if err != nil {
return err
}

fmt.Printf("Partition Index: %d\n", pIdx)
fmt.Printf("Sectors: %d\n", sectorCount)
fmt.Printf("Sector Numbers: %v\n", sectorNumbers)
fmt.Printf("Faults: %d\n", faultsCount)
fmt.Printf("Faulty Sectors: %d\n", fn)
sectorNumbers, err := partition.LiveSectors.All(sectorCount)
if err != nil {
return err
}

faultsCount, err := partition.FaultySectors.Count()
if err != nil {
return err
}

fn, err := partition.FaultySectors.All(faultsCount)
if err != nil {
return err
}

fmt.Printf("Partition Index: %d\n", pIdx)
fmt.Printf("Sectors: %d\n", sectorCount)
fmt.Printf("Sector Numbers: %v\n", sectorNumbers)
fmt.Printf("Faults: %d\n", faultsCount)
fmt.Printf("Faulty Sectors: %d\n", fn)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here, only put the if/else around the code that is different.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@geoff-vball Sorry, I originally generated redundant code in order to reduce the number of judgments, and it has been corrected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants