Merge pull request #1786 from filecoin-project/asr/clideal

Prevent client list-deals from crashing
This commit is contained in:
Łukasz Magiera 2020-05-18 23:48:33 +02:00 committed by GitHub
commit f99c5416ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -501,17 +501,28 @@ var clientListDeals = &cli.Command{
} }
var deals []deal var deals []deal
for idx := range localDeals { for _, v := range localDeals {
onChain, err := api.StateMarketStorageDeal(ctx, localDeals[idx].DealID, head.Key()) if v.DealID == 0 {
deals = append(deals, deal{
LocalDeal: v,
OnChainDealState: market.DealState{
SectorStartEpoch: -1,
LastUpdatedEpoch: -1,
SlashEpoch: -1,
},
})
} else {
onChain, err := api.StateMarketStorageDeal(ctx, v.DealID, head.Key())
if err != nil { if err != nil {
return err return err
} }
deals = append(deals, deal{ deals = append(deals, deal{
LocalDeal: localDeals[idx], LocalDeal: v,
OnChainDealState: onChain.State, OnChainDealState: onChain.State,
}) })
} }
}
w := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0) w := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
fmt.Fprintf(w, "DealCid\tDealId\tProvider\tState\tOn Chain?\tSlashed?\tPieceCID\tSize\tPrice\tDuration\tMessage\n") fmt.Fprintf(w, "DealCid\tDealId\tProvider\tState\tOn Chain?\tSlashed?\tPieceCID\tSize\tPrice\tDuration\tMessage\n")