Skip to content

Commit

Permalink
Fixup get-cc-collateral command
Browse files Browse the repository at this point in the history
  • Loading branch information
arajasek committed Feb 28, 2021
1 parent c9c26ee commit 191a05d
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions cmd/lotus-storage-miner/sectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,18 +655,45 @@ var sectorsCapacityCollateralCmd = &cli.Command{
return err
}

mi, err := nApi.StateMinerInfo(ctx, maddr, types.EmptyTSK)
if err != nil {
return err
}

nv, err := nApi.StateNetworkVersion(ctx, types.EmptyTSK)
if err != nil {
return err
}

spt, err := miner.PreferredSealProofTypeFromWindowPoStType(nv, mi.WindowPoStProofType)
if err != nil {
return err
}

pci := miner.SectorPreCommitInfo{
SealProof: spt,
Expiration: abi.ChainEpoch(cctx.Uint64("expiration")),
}
if pci.Expiration == 0 {
pci.Expiration = policy.GetMaxSectorExpirationExtension()
h, err := nApi.ChainHead(ctx)
if err != nil {
return err
}

pci.Expiration = policy.GetMaxSectorExpirationExtension() + h.Height()
}

pc, err := nApi.StateMinerInitialPledgeCollateral(ctx, maddr, pci, types.EmptyTSK)
if err != nil {
return err
}

fmt.Printf("Estimated collateral: %s\n", types.FIL(pc))
pcd, err := nApi.StateMinerPreCommitDepositForPower(ctx, maddr, pci, types.EmptyTSK)
if err != nil {
return err
}

fmt.Printf("Estimated collateral: %s\n", types.FIL(big.Max(pc, pcd)))

return nil
},
Expand Down

1 comment on commit 191a05d

@magik6k
Copy link
Contributor

Choose a reason for hiding this comment

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

Lgtm

Please sign in to comment.